Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/create_snippet_service.rb6
-rw-r--r--app/services/issuable_base_service.rb12
-rw-r--r--app/services/notes/create_service.rb6
-rw-r--r--app/services/notes/update_service.rb6
-rw-r--r--app/services/update_snippet_service.rb8
5 files changed, 31 insertions, 7 deletions
diff --git a/app/services/create_snippet_service.rb b/app/services/create_snippet_service.rb
index 0aa76df35ba..eacea7d94c7 100644
--- a/app/services/create_snippet_service.rb
+++ b/app/services/create_snippet_service.rb
@@ -21,7 +21,11 @@ class CreateSnippetService < BaseService
spam_check(snippet, current_user)
- if snippet.save
+ snippet_saved = snippet.with_transaction_returning_status do
+ snippet.save && snippet.store_mentions!
+ end
+
+ if snippet_saved
UserAgentDetailService.new(snippet, @request).create
Gitlab::UsageDataCounters::SnippetCounter.count(:create)
end
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index bb65a8f402d..6cb84458d9b 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -163,7 +163,11 @@ class IssuableBaseService < BaseService
before_create(issuable)
- if issuable.save
+ issuable_saved = issuable.with_transaction_returning_status do
+ issuable.save && issuable.store_mentions!
+ end
+
+ if issuable_saved
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, is_update: false)
after_create(issuable)
@@ -224,7 +228,11 @@ class IssuableBaseService < BaseService
update_project_counters = issuable.project && update_project_counter_caches?(issuable)
ensure_milestone_available(issuable)
- if issuable.with_transaction_returning_status { issuable.save(touch: should_touch) }
+ issuable_saved = issuable.with_transaction_returning_status do
+ issuable.save(touch: should_touch) && issuable.store_mentions!
+ end
+
+ if issuable_saved
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: old_associations[:labels])
handle_changes(issuable, old_associations: old_associations)
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb
index 9e6cbfa06fe..3468341a0f2 100644
--- a/app/services/notes/create_service.rb
+++ b/app/services/notes/create_service.rb
@@ -33,7 +33,11 @@ module Notes
NewNoteWorker.perform_async(note.id)
end
- if !only_commands && note.save
+ note_saved = note.with_transaction_returning_status do
+ !only_commands && note.save && note.store_mentions!
+ end
+
+ if note_saved
if note.part_of_discussion? && note.discussion.can_convert_to_discussion?
note.discussion.convert_to_discussion!(save: true)
end
diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb
index 573be8fbe8b..15c556498ec 100644
--- a/app/services/notes/update_service.rb
+++ b/app/services/notes/update_service.rb
@@ -7,7 +7,11 @@ module Notes
old_mentioned_users = note.mentioned_users(current_user).to_a
- note.update(params.merge(updated_by: current_user))
+ note.assign_attributes(params.merge(updated_by: current_user))
+
+ note.with_transaction_returning_status do
+ note.save && note.store_mentions!
+ end
only_commands = false
diff --git a/app/services/update_snippet_service.rb b/app/services/update_snippet_service.rb
index a294812ef9e..ac7f8e9b1f5 100644
--- a/app/services/update_snippet_service.rb
+++ b/app/services/update_snippet_service.rb
@@ -25,8 +25,12 @@ class UpdateSnippetService < BaseService
snippet.assign_attributes(params)
spam_check(snippet, current_user)
- snippet.save.tap do |succeeded|
- Gitlab::UsageDataCounters::SnippetCounter.count(:update) if succeeded
+ snippet_saved = snippet.with_transaction_returning_status do
+ snippet.save && snippet.store_mentions!
+ end
+
+ if snippet_saved
+ Gitlab::UsageDataCounters::SnippetCounter.count(:update)
end
end
end