mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 05:02:50 +08:00
Merge pull request #3459 from artoscinote/ma_SCI_5662
Corrected type for 'assignment' activities [SCI-5662]
This commit is contained in:
commit
e337fda414
2 changed files with 22 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue