From 5c4f92385479985905bdbb1829688cbb61a799b6 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Thu, 29 Jul 2021 10:13:28 +0200 Subject: [PATCH] Corrected type for 'assignment' activities [SCI-5662] --- app/models/activity.rb | 11 +++++++++++ app/models/concerns/generate_notification_model.rb | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index 851ea8287..588928af7 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,6 +1,17 @@ # frozen_string_literal: true class Activity < ApplicationRecord + ASSIGNMENT_TYPES = %w( + assign_user_to_project + change_user_role_on_project + unassign_user_from_project + assign_user_to_module + unassign_user_from_module + invite_user_to_team + remove_user_from_team + change_users_role_on_team + ).freeze + include ActivityValuesModel include GenerateNotificationModel diff --git a/app/models/concerns/generate_notification_model.rb b/app/models/concerns/generate_notification_model.rb index 0f9a12e53..643526c54 100644 --- a/app/models/concerns/generate_notification_model.rb +++ b/app/models/concerns/generate_notification_model.rb @@ -15,7 +15,7 @@ module GenerateNotificationModel description = generate_notification_description_elements(subject).reverse.join(' | ') notification = Notification.create( - type_of: :recent_changes, + type_of: notification_type, title: sanitize_input(message, %w(strong a)), message: sanitize_input(description, %w(strong a)), generator_user_id: owner.id @@ -114,4 +114,14 @@ module GenerateNotificationModel def generate_notification CreateNotificationFromActivityJob.perform_later(self) if notifiable? end + + def notification_type + return :recent_changes unless instance_of?(Activity) + + if type_of.in? Activity::ASSIGNMENT_TYPES + :assignment + else + :recent_changes + end + end end