2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-21 03:23:09 -05:00
|
|
|
%i(
|
|
|
|
topic_recovered
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |topic, _|
|
|
|
|
WebHook.enqueue_topic_hooks(event, topic)
|
2017-04-11 20:50:03 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-26 21:07:37 -06:00
|
|
|
DiscourseEvent.on(:topic_status_updated) do |topic, status|
|
|
|
|
WebHook.enqueue_topic_hooks("topic_#{status}_status_updated", topic)
|
|
|
|
end
|
|
|
|
|
2018-05-21 03:23:09 -05:00
|
|
|
DiscourseEvent.on(:topic_created) do |topic, _, _|
|
|
|
|
WebHook.enqueue_topic_hooks(:topic_created, topic)
|
2017-04-11 20:50:03 -05:00
|
|
|
end
|
|
|
|
|
2018-05-21 03:23:09 -05:00
|
|
|
%i(
|
|
|
|
post_created
|
|
|
|
post_recovered
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |post, _, _|
|
|
|
|
WebHook.enqueue_post_hooks(event, post)
|
2017-04-11 20:50:03 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
DiscourseEvent.on(:post_edited) do |post, topic_changed|
|
2018-01-22 13:58:01 -06: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-11 20:50:03 -05:00
|
|
|
end
|
|
|
|
|
2017-12-20 03:47:30 -06:00
|
|
|
%i(
|
|
|
|
user_logged_out
|
|
|
|
user_created
|
|
|
|
user_logged_in
|
|
|
|
user_approved
|
|
|
|
user_updated
|
|
|
|
).each do |event|
|
2017-04-11 20:50:03 -05:00
|
|
|
DiscourseEvent.on(event) do |user|
|
2018-05-21 03:23:09 -05:00
|
|
|
WebHook.enqueue_object_hooks(:user, user, event)
|
2017-04-11 20:50:03 -05:00
|
|
|
end
|
|
|
|
end
|
2018-03-27 01:23:35 -05:00
|
|
|
|
|
|
|
%i(
|
|
|
|
group_created
|
|
|
|
group_updated
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |group|
|
2018-05-21 03:23:09 -05:00
|
|
|
WebHook.enqueue_object_hooks(:group, group, event)
|
2018-03-27 01:23:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
%i(
|
|
|
|
category_created
|
|
|
|
category_updated
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |category|
|
2018-05-21 03:23:09 -05:00
|
|
|
WebHook.enqueue_object_hooks(:category, category, event)
|
2018-03-27 01:23:35 -05:00
|
|
|
end
|
|
|
|
end
|
2018-04-04 07:19:20 -05:00
|
|
|
|
|
|
|
%i(
|
|
|
|
tag_created
|
|
|
|
tag_updated
|
|
|
|
).each do |event|
|
|
|
|
DiscourseEvent.on(event) do |tag|
|
2018-05-21 04:29:19 -05:00
|
|
|
WebHook.enqueue_object_hooks(:tag, tag, event, TagSerializer)
|
2018-04-04 07:19:20 -05:00
|
|
|
end
|
|
|
|
end
|
2018-04-11 09:17:05 -05:00
|
|
|
|
2020-04-08 13:34:35 -05:00
|
|
|
%i(
|
|
|
|
user_badge_granted
|
|
|
|
).each do |event|
|
|
|
|
# user_badge_revoked
|
|
|
|
DiscourseEvent.on(event) do |badge, user_id|
|
|
|
|
ub = UserBadge.find_by(badge: badge, user_id: user_id)
|
|
|
|
WebHook.enqueue_object_hooks(:user_badge, ub, event, UserBadgeSerializer)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-03 11:03:01 -06: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-25 12:54:43 -05:00
|
|
|
end
|
2019-08-15 13:45:30 -05:00
|
|
|
|
|
|
|
DiscourseEvent.on(:notification_created) do |notification|
|
|
|
|
WebHook.enqueue_object_hooks(:notification, notification, :notification_created, NotificationSerializer)
|
|
|
|
end
|