Skip to content

Commit

Permalink
FEATURE: add topic_slug to the upvote event payload (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
renato committed Aug 15, 2023
1 parent cbef1af commit 8427963
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/discourse_topic_voting/votes_controller.rb
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions spec/requests/votes_controller_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 8427963

Please sign in to comment.