2023-12-27 16:19:19 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-29 22:51:27 +08:00
|
|
|
module NotificationsHelper
|
2016-10-05 16:52:27 +08:00
|
|
|
def send_email_notification(user, notification)
|
2023-08-11 21:31:29 +08:00
|
|
|
AppMailer.delay.notification(user.id, notification)
|
2016-10-05 16:52:27 +08:00
|
|
|
end
|
2016-11-07 22:31:06 +08:00
|
|
|
|
2019-07-01 19:44:27 +08:00
|
|
|
# generate assignment notification
|
|
|
|
def generate_notification(user, target_user, team, role)
|
2017-01-25 16:48:49 +08:00
|
|
|
if team
|
|
|
|
title = I18n.t('notifications.unassign_user_from_team',
|
2016-11-08 18:20:14 +08:00
|
|
|
unassigned_user: target_user.name,
|
2017-01-25 16:48:49 +08:00
|
|
|
team: team.name,
|
2016-11-08 18:20:14 +08:00
|
|
|
unassigned_by_user: user.name)
|
2023-11-23 17:34:07 +08:00
|
|
|
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
|
2016-11-07 22:31:06 +08:00
|
|
|
end
|
|
|
|
|
2024-01-04 07:31:46 +08:00
|
|
|
GeneralNotification.send_notifications(
|
|
|
|
{
|
|
|
|
type: role ? :invite_user_to_team : :remove_user_from_team,
|
|
|
|
title: sanitize_input(title),
|
|
|
|
subject_id: team.id,
|
|
|
|
subject_class: team.class.name,
|
|
|
|
subject_name: team.respond_to?(:name) && team.name,
|
|
|
|
user: target_user
|
|
|
|
}
|
|
|
|
)
|
2016-11-07 22:31:06 +08:00
|
|
|
end
|
2016-09-29 22:51:27 +08:00
|
|
|
end
|