From c766ac9d3f35e32c6ace7e46741cc97c568c4faf Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 26 Oct 2020 22:30:14 -0400 Subject: [PATCH] change topic notification to post notification (derpibooru/philomena#191, derpibooru/philomena#39) --- lib/philomena/topics.ex | 14 +++++++------- lib/philomena_web/controllers/topic_controller.ex | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/philomena/topics.ex b/lib/philomena/topics.ex index f46f36ef..1bdab9c4 100644 --- a/lib/philomena/topics.ex +++ b/lib/philomena/topics.ex @@ -73,7 +73,7 @@ defmodule Philomena.Topics do |> Repo.transaction() end - def notify_topic(topic) do + def notify_topic(topic, post) do spawn(fn -> forum = topic @@ -86,14 +86,14 @@ defmodule Philomena.Topics do |> Map.fetch!(:subscriptions) Notifications.notify( - topic, + post, subscriptions, %{ - actor_id: forum.id, - actor_type: "Forum", - actor_child_id: topic.id, - actor_child_type: "Topic", - action: "posted a new topic" + actor_id: topic.id, + actor_type: "Topic", + actor_child_id: post.id, + actor_child_type: "Post", + action: "posted a new topic in #{forum.name}" } ) end) diff --git a/lib/philomena_web/controllers/topic_controller.ex b/lib/philomena_web/controllers/topic_controller.ex index ea2dc4b8..4b411061 100644 --- a/lib/philomena_web/controllers/topic_controller.ex +++ b/lib/philomena_web/controllers/topic_controller.ex @@ -113,7 +113,7 @@ defmodule PhilomenaWeb.TopicController do {:ok, %{topic: topic}} -> post = hd(topic.posts) Posts.reindex_post(post) - Topics.notify_topic(topic) + Topics.notify_topic(topic, post) if forum.access_level == "normal" do PhilomenaWeb.Endpoint.broadcast!(