From 28926257f478fc858a7f90a302d3f6f9336188de Mon Sep 17 00:00:00 2001 From: Renato Atilio Date: Tue, 15 Aug 2023 16:07:08 -0300 Subject: [PATCH] FEATURE: add topic_slug to the upvote event payload --- app/controllers/discourse_topic_voting/votes_controller.rb | 7 ++++++- spec/requests/votes_controller_spec.rb | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/discourse_topic_voting/votes_controller.rb b/app/controllers/discourse_topic_voting/votes_controller.rb index 4d40673..22da37c 100644 --- a/app/controllers/discourse_topic_voting/votes_controller.rb +++ b/app/controllers/discourse_topic_voting/votes_controller.rb @@ -40,7 +40,12 @@ def vote } if WebHook.active_web_hooks(:topic_voting).exists? - payload = { topic_id: topic_id, voter_id: current_user.id, vote_count: obj[:vote_count] } + payload = { + topic_id: topic_id, + topic_slug: topic.slug, + voter_id: current_user.id, + vote_count: obj[:vote_count], + } WebHook.enqueue_topic_voting_hooks(:topic_upvote, topic, payload.to_json) end diff --git a/spec/requests/votes_controller_spec.rb b/spec/requests/votes_controller_spec.rb index f6f6553..ce989de 100644 --- a/spec/requests/votes_controller_spec.rb +++ b/spec/requests/votes_controller_spec.rb @@ -55,6 +55,7 @@ expect(job_args["event_name"]).to eq("topic_upvote") payload = JSON.parse(job_args["payload"]) expect(payload["topic_id"]).to eq(topic.id) + expect(payload["topic_slug"]).to eq(topic.slug) expect(payload["voter_id"]).to eq(user.id) expect(payload["vote_count"]).to eq(1) end