Commit 5753de3a authored by allison.browne's avatar allison.browne

Update zoom note service to use ZoomMeeting

Previously the ZoomNotesService looked at the last peice
of the description for a link matching a zoom url
Now it can use the ActiveRecord ZoomMeeting model
parent d9d30da8
...@@ -281,7 +281,7 @@ module IssuablesHelper ...@@ -281,7 +281,7 @@ module IssuablesHelper
} }
data[:hasClosingMergeRequest] = issuable.merge_requests_count(current_user) != 0 if issuable.is_a?(Issue) data[:hasClosingMergeRequest] = issuable.merge_requests_count(current_user) != 0 if issuable.is_a?(Issue)
data[:zoomMeetingUrl] = issuable&.zoom_meetings.added_to_issue.first&.url data[:zoomMeetingUrl] = ZoomMeeting.canonical_meeting_url(issuable)
if parent.is_a?(Group) if parent.is_a?(Group)
data[:groupPath] = parent.path data[:groupPath] = parent.path
......
...@@ -14,4 +14,14 @@ class ZoomMeeting < ApplicationRecord ...@@ -14,4 +14,14 @@ class ZoomMeeting < ApplicationRecord
scope :added_to_issue, -> { where(issue_status: :added) } scope :added_to_issue, -> { where(issue_status: :added) }
scope :removed_from_issue, -> { where(issue_status: :removed) } scope :removed_from_issue, -> { where(issue_status: :removed) }
class << self
def canonical_meeting_url(issue)
canonical_meeting(issue)&.url
end
def canonical_meeting(issue)
issue&.zoom_meetings&.added_to_issue&.first
end
end
end end
...@@ -62,7 +62,7 @@ module Issues ...@@ -62,7 +62,7 @@ module Issues
notification_service.async.new_mentions_in_issue(issue, added_mentions, current_user) notification_service.async.new_mentions_in_issue(issue, added_mentions, current_user)
end end
ZoomNotesService.new(issue, project, current_user, old_description: old_associations[:description]).execute ZoomNotesService.new(issue, project, current_user, old_zoom_meetings: old_associations[:zoom_meetings]).execute
end end
def handle_task_changes(issuable) def handle_task_changes(issuable)
......
# frozen_string_literal: true # frozen_string_literal: true
class ZoomNotesService class ZoomNotesService
def initialize(issue, project, current_user, old_description: nil) def initialize(issue, project, current_user, old_zoom_meetings: nil)
@issue = issue @issue = issue
@project = project @project = project
@current_user = current_user @current_user = current_user
@old_description = old_description @old_zoom_meetings = old_zoom_meetings
end end
def execute def execute
return if @issue.description == @old_description return if @issue.zoom_meetings == @zoom_meetings
if zoom_link_added? if zoom_link_added?
zoom_link_added_notification zoom_link_added_notification
elsif zoom_link_removed? else
zoom_link_removed_notification zoom_link_removed_notification
end end
end end
...@@ -21,15 +21,7 @@ class ZoomNotesService ...@@ -21,15 +21,7 @@ class ZoomNotesService
private private
def zoom_link_added? def zoom_link_added?
has_zoom_link?(@issue.description) && !has_zoom_link?(@old_description) ZoomMeeting.canonical_meeting_url(@issue)
end
def zoom_link_removed?
!has_zoom_link?(@issue.description) && has_zoom_link?(@old_description)
end
def has_zoom_link?(text)
Gitlab::ZoomLinkExtractor.new(text).match?
end end
def zoom_link_added_notification def zoom_link_added_notification
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment