mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Fix invitation notifications [SCI-9609]
This commit is contained in:
parent
0ec734b467
commit
b18b1d9697
3 changed files with 30 additions and 15 deletions
|
@ -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
|
||||
|
|
11
app/notifications/recipients/direct_recipient.rb
Normal file
11
app/notifications/recipients/direct_recipient.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Recipients::DirectRecipient
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def recipients
|
||||
[@params[:user]]
|
||||
end
|
||||
end
|
|
@ -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
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue