summaryrefslogtreecommitdiff
path: root/app/services/issues
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 18:07:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 18:07:34 +0000
commit90859e80ca23b8709d56b60d2066b569053e7e02 (patch)
tree15d9ac5c194220fab358c42325645fdf2c6ead13 /app/services/issues
parent7530cf5ad8dd86fbe19e129b6bb31b23849ed757 (diff)
downloadgitlab-ce-90859e80ca23b8709d56b60d2066b569053e7e02.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/issues')
-rw-r--r--app/services/issues/zoom_link_service.rb50
1 files changed, 34 insertions, 16 deletions
diff --git a/app/services/issues/zoom_link_service.rb b/app/services/issues/zoom_link_service.rb
index 023d7080e88..9572cf50564 100644
--- a/app/services/issues/zoom_link_service.rb
+++ b/app/services/issues/zoom_link_service.rb
@@ -13,30 +13,29 @@ module Issues
if can_add_link? && (link = parse_link(link))
begin
add_zoom_meeting(link)
- success(_('Zoom meeting added'))
rescue ActiveRecord::RecordNotUnique
- error(_('Failed to add a Zoom meeting'))
+ error(message: _('Failed to add a Zoom meeting'))
end
else
- error(_('Failed to add a Zoom meeting'))
+ error(message: _('Failed to add a Zoom meeting'))
end
end
def remove_link
if can_remove_link?
remove_zoom_meeting
- success(_('Zoom meeting removed'))
+ success(message: _('Zoom meeting removed'))
else
- error(_('Failed to remove a Zoom meeting'))
+ error(message: _('Failed to remove a Zoom meeting'))
end
end
def can_add_link?
- can_update_issue? && !@added_meeting
+ can_change_link? && !@added_meeting
end
def can_remove_link?
- can_update_issue? && !!@added_meeting
+ can_change_link? && @issue.persisted? && !!@added_meeting
end
def parse_link(link)
@@ -56,14 +55,29 @@ module Issues
end
def add_zoom_meeting(link)
- ZoomMeeting.create(
+ zoom_meeting = new_zoom_meeting(link)
+ response =
+ if @issue.persisted?
+ # Save the meeting directly since we only want to update one meeting, not all
+ zoom_meeting.save
+ success(message: _('Zoom meeting added'))
+ else
+ success(message: _('Zoom meeting added'), payload: { zoom_meetings: [zoom_meeting] })
+ end
+
+ track_meeting_added_event
+ SystemNoteService.zoom_link_added(@issue, @project, current_user)
+
+ response
+ end
+
+ def new_zoom_meeting(link)
+ ZoomMeeting.new(
issue: @issue,
- project: @issue.project,
+ project: @project,
issue_status: :added,
url: link
)
- track_meeting_added_event
- SystemNoteService.zoom_link_added(@issue, @project, current_user)
end
def remove_zoom_meeting
@@ -72,16 +86,20 @@ module Issues
SystemNoteService.zoom_link_removed(@issue, @project, current_user)
end
- def success(message)
- ServiceResponse.success(message: message)
+ def success(message:, payload: nil)
+ ServiceResponse.success(message: message, payload: payload)
end
- def error(message)
+ def error(message:)
ServiceResponse.error(message: message)
end
- def can_update_issue?
- can?(current_user, :update_issue, project)
+ def can_change_link?
+ if @issue.persisted?
+ can?(current_user, :update_issue, @project)
+ else
+ can?(current_user, :create_issue, @project)
+ end
end
end
end