2021-06-17 20:54:30 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Activities
|
|
|
|
class ActivityWebhookService
|
|
|
|
def initialize(webhook, activity)
|
|
|
|
@webhook = webhook
|
|
|
|
@activity = activity
|
|
|
|
end
|
|
|
|
|
|
|
|
def send_webhook
|
|
|
|
WebhookService.new(@webhook, activity_payload).send_webhook
|
|
|
|
end
|
|
|
|
|
|
|
|
def activity_payload
|
|
|
|
@activity.values.merge(
|
|
|
|
type: @activity.type_of,
|
2021-08-06 19:43:30 +08:00
|
|
|
created_at: @activity.created_at,
|
|
|
|
subject: {
|
|
|
|
type: @activity.subject_type,
|
|
|
|
id: @activity.subject_id
|
2023-08-23 22:49:17 +08:00
|
|
|
},
|
|
|
|
subject_breadcrumbs: @activity.subject_parents.map do |subject|
|
|
|
|
{ type: subject.model_name.human.downcase, id: subject.id }
|
|
|
|
end
|
2021-06-17 20:54:30 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|