Fix invitation notifications [SCI-9609]

This commit is contained in:
Anton 2023-11-23 10:34:07 +01:00
parent 0ec734b467
commit b18b1d9697
3 changed files with 30 additions and 15 deletions

View file

@ -10,17 +10,21 @@ module NotificationsHelper
unassigned_user: target_user.name,
team: team.name,
unassigned_by_user: user.name)
title = I18n.t('notifications.assign_user_to_team',
assigned_user: target_user.name,
role: role,
team: team.name,
assigned_by_user: user.name) if role
if role
title = I18n.t('notifications.assign_user_to_team',
assigned_user: target_user.name,
role: role,
team: team.name,
assigned_by_user: user.name)
end
message = "#{I18n.t('search.index.team')} #{team.name}"
end
GeneralNotification.with(
title: sanitize_input(title),
message: sanitize_input(message)
).deliver_later(target_user)
GeneralNotification.send_notifications({
type: role ? :invite_user_to_team : :remove_user_from_team,
title: sanitize_input(title),
message: sanitize_input(message),
user: target_user
})
end
end

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class Recipients::DirectRecipient
def initialize(params)
@params = params
end
def recipients
[@params[:user]]
end
end

View file

@ -86,13 +86,13 @@ class NotificationExtends
smart_annotation_added: {
recipients_module: :AnnotatedRecipients
},
invite_user_to_team_activity: {
invite_user_to_team: {
code: 92,
recipients_module: :AssignedRecipients
recipients_module: :DirectRecipient
},
remove_user_from_team_activity: {
remove_user_from_team: {
code: 93,
recipients_module: :AssignedRecipients
recipients_module: :DirectRecipient
},
change_users_role_on_team_activity: {
code: 94,
@ -148,8 +148,8 @@ class NotificationExtends
smart_annotation_added
],
other_team_invitation: %I[
invite_user_to_team_activity
remove_user_from_team_activity
invite_user_to_team
remove_user_from_team
change_users_role_on_team_activity
]
}