2023-10-17 18:02:55 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Recipients::MyModuleDesignatedRecipients
|
|
|
|
def initialize(params)
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def recipients
|
|
|
|
if @params[:activity_id]
|
|
|
|
activity_recipients
|
|
|
|
else
|
2023-11-29 09:12:02 +08:00
|
|
|
MyModule.find(@params[:my_module_id]).designated_users
|
2023-10-17 18:02:55 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def activity_recipients
|
|
|
|
activity = Activity.find(@params[:activity_id])
|
|
|
|
case activity.subject_type
|
|
|
|
when 'MyModule'
|
|
|
|
users = activity.subject.designated_users
|
|
|
|
when 'Protocol', 'Result'
|
|
|
|
users = activity.subject.my_module.designated_users
|
|
|
|
when 'Step'
|
|
|
|
users = activity.subject.protocol.my_module.designated_users
|
|
|
|
end
|
|
|
|
|
|
|
|
users.where.not(id: activity.owner_id)
|
|
|
|
end
|
|
|
|
end
|