Merge pull request #3459 from artoscinote/ma_SCI_5662

Corrected type for 'assignment' activities [SCI-5662]
This commit is contained in:
artoscinote 2021-07-29 10:54:16 +02:00 committed by GitHub
commit e337fda414
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -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

View file

@ -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