From 8c316805735561290884760b9828795071ea26c5 Mon Sep 17 00:00:00 2001 From: Ivan Kljun Date: Tue, 5 Dec 2023 10:07:45 +0100 Subject: [PATCH] Create RepositoryItemRecipients for Low Stock and Date/Date&Time notifications [SCI-9782] --- .../recipients/repository_item_recipients.rb | 12 ++++++++++++ .../recipients/repository_row_creator.rb | 11 ----------- config/initializers/extends/notification_extends.rb | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 app/notifications/recipients/repository_item_recipients.rb delete mode 100644 app/notifications/recipients/repository_row_creator.rb diff --git a/app/notifications/recipients/repository_item_recipients.rb b/app/notifications/recipients/repository_item_recipients.rb new file mode 100644 index 000000000..bf1f0ad85 --- /dev/null +++ b/app/notifications/recipients/repository_item_recipients.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class Recipients::RepositoryItemRecipients + def initialize(params) + @repository_row_id = params[:repository_row_id] + end + + def recipients + repository_row = RepositoryRow.find(@repository_row_id) + repository_row.repository.team.users + end +end diff --git a/app/notifications/recipients/repository_row_creator.rb b/app/notifications/recipients/repository_row_creator.rb deleted file mode 100644 index aa02c54d1..000000000 --- a/app/notifications/recipients/repository_row_creator.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Recipients::RepositoryRowCreator - def initialize(params) - @params = params - end - - def recipients - [RepositoryRow.find(@params[:repository_row_id]).created_by] - end -end diff --git a/config/initializers/extends/notification_extends.rb b/config/initializers/extends/notification_extends.rb index 8f2dfbb00..60a023ecc 100644 --- a/config/initializers/extends/notification_extends.rb +++ b/config/initializers/extends/notification_extends.rb @@ -78,10 +78,10 @@ class NotificationExtends recipients_module: :AssignedRecipients }, item_low_stock_reminder: { - recipients_module: :RepositoryRowCreator + recipients_module: :RepositoryItemRecipients }, item_date_reminder: { - recipients_module: :RepositoryRowCreator + recipients_module: :RepositoryItemRecipients }, smart_annotation_added: { recipients_module: :DirectRecipient