2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-21 16:23:09 +08:00
|
|
|
%i(
|
|
|
|
topic_recovered
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |topic, _|
|
|
|
|
WebHook.enqueue_topic_hooks(event, topic)
|
2017-04-12 09:50:03 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-27 11:07:37 +08:00
|
|
|
DiscourseEvent.on(:topic_status_updated) do |topic, status|
|
|
|
|
WebHook.enqueue_topic_hooks("topic_#{status}_status_updated", topic)
|
|
|
|
end
|
|
|
|
|
2018-05-21 16:23:09 +08:00
|
|
|
DiscourseEvent.on(:topic_created) do |topic, _, _|
|
|
|
|
WebHook.enqueue_topic_hooks(:topic_created, topic)
|
2017-04-12 09:50:03 +08:00
|
|
|
end
|
|
|
|
|
2018-05-21 16:23:09 +08:00
|
|
|
%i(
|
|
|
|
post_created
|
|
|
|
post_recovered
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |post, _, _|
|
|
|
|
WebHook.enqueue_post_hooks(event, post)
|
2017-04-12 09:50:03 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
DiscourseEvent.on(:post_edited) do |post, topic_changed|
|
2018-01-23 03:58:01 +08:00
|
|
|
if post.topic
|
|
|
|
WebHook.enqueue_post_hooks(:post_edited, post)
|
|
|
|
|
|
|
|
if post.is_first_post? && topic_changed
|
|
|
|
WebHook.enqueue_topic_hooks(:topic_edited, post.topic)
|
|
|
|
end
|
|
|
|
end
|
2017-04-12 09:50:03 +08:00
|
|
|
end
|
|
|
|
|
2017-12-20 17:47:30 +08:00
|
|
|
%i(
|
|
|
|
user_logged_out
|
|
|
|
user_created
|
|
|
|
user_logged_in
|
|
|
|
user_approved
|
|
|
|
user_updated
|
|
|
|
).each do |event|
|
2017-04-12 09:50:03 +08:00
|
|
|
DiscourseEvent.on(event) do |user|
|
2018-05-21 16:23:09 +08:00
|
|
|
WebHook.enqueue_object_hooks(:user, user, event)
|
2017-04-12 09:50:03 +08:00
|
|
|
end
|
|
|
|
end
|
2018-03-27 14:23:35 +08:00
|
|
|
|
|
|
|
%i(
|
|
|
|
group_created
|
|
|
|
group_updated
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |group|
|
2018-05-21 16:23:09 +08:00
|
|
|
WebHook.enqueue_object_hooks(:group, group, event)
|
2018-03-27 14:23:35 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
%i(
|
|
|
|
category_created
|
|
|
|
category_updated
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |category|
|
2018-05-21 16:23:09 +08:00
|
|
|
WebHook.enqueue_object_hooks(:category, category, event)
|
2018-03-27 14:23:35 +08:00
|
|
|
end
|
|
|
|
end
|
2018-04-04 20:19:20 +08:00
|
|
|
|
|
|
|
%i(
|
|
|
|
tag_created
|
|
|
|
tag_updated
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |tag|
|
2018-05-21 17:29:19 +08:00
|
|
|
WebHook.enqueue_object_hooks(:tag, tag, event, TagSerializer)
|
2018-04-04 20:19:20 +08:00
|
|
|
end
|
|
|
|
end
|
2018-04-11 22:17:05 +08:00
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
DiscourseEvent.on(:reviewable_created) do |reviewable|
|
|
|
|
WebHook.enqueue_object_hooks(:reviewable, reviewable, :reviewable_created, reviewable.serializer)
|
|
|
|
end
|
|
|
|
|
|
|
|
DiscourseEvent.on(:reviewable_transitioned_to) do |status, reviewable|
|
|
|
|
WebHook.enqueue_object_hooks(:reviewable, reviewable, :reviewable_transitioned_to, reviewable.serializer)
|
2018-07-26 01:54:43 +08:00
|
|
|
end
|
2019-08-16 02:45:30 +08:00
|
|
|
|
|
|
|
DiscourseEvent.on(:notification_created) do |notification|
|
|
|
|
WebHook.enqueue_object_hooks(:notification, notification, :notification_created, NotificationSerializer)
|
|
|
|
end
|