scinote-web/app/helpers/notifications_helper.rb

27 lines
916 B
Ruby
Raw Normal View History

module NotificationsHelper
2016-10-05 16:52:27 +08:00
def send_email_notification(user, notification)
AppMailer.delay.notification(user.id, notification)
2016-10-05 16:52:27 +08:00
end
2016-11-07 22:31:06 +08:00
# generate assignment notification
def generate_notification(user, target_user, team, role)
if team
title = I18n.t('notifications.unassign_user_from_team',
2016-11-08 18:20:14 +08:00
unassigned_user: target_user.name,
team: team.name,
2016-11-08 18:20:14 +08:00
unassigned_by_user: user.name)
title = I18n.t('notifications.assign_user_to_team',
2016-11-08 18:20:14 +08:00
assigned_user: target_user.name,
role: role,
team: team.name,
2016-11-08 18:20:14 +08:00
assigned_by_user: user.name) if role
message = "#{I18n.t('search.index.team')} #{team.name}"
2016-11-07 22:31:06 +08:00
end
2023-10-11 19:43:20 +08:00
GeneralNotification.with(
title: sanitize_input(title),
message: sanitize_input(message)
2023-10-11 19:43:20 +08:00
).deliver_later(target_user)
2016-11-07 22:31:06 +08:00
end
end