docbrown/app/workers/mentions/create_all_worker.rb
Vaidehi Joshi 8f0c24c167
Expand @-mention functionality to posts (#13367)
* Initial work for @-mention notifications from posts

* Revert article.published changes to article updater, add clarifying comments

* Extract article preview into reusable partial for notification views

* Clean up Article Updater

* Address + remove some FIXMEs

* Add a whole buncha specs for @-mention functionality in posts YAY

* Refactor create all spec to use shared examples, add clarifying comments

* Add guard clause to create all service

* Update new mention and notifiable action specs

* Some additional cleanup

* Add specs + shared examples to SendEmailNotificationWorker spec

* Use aggregate_failures where applicable

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Cleanup and address code review comments

* Add MentionDecorator + relevant specs

* Address comments/issues flagged by @rhymes

* Optimize plucking user_ids when checking for article followers

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-05-12 07:33:33 -07:00

14 lines
436 B
Ruby

module Mentions
# This worker is currently only used to create mentions on comments.
class CreateAllWorker
include Sidekiq::Worker
sidekiq_options queue: :default, retry: 10
def perform(notifiable_id, notifiable_type)
return if ["Comment"].none?(notifiable_type)
notifiable = notifiable_type.constantize.find_by(id: notifiable_id)
Mentions::CreateAll.call(notifiable) if notifiable
end
end
end