From 11276b2339038048508c93276fe4ae78a21f44ac Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Wed, 9 Sep 2020 22:47:35 -0400 Subject: [PATCH] re-add merge notification --- lib/philomena/images.ex | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/philomena/images.ex b/lib/philomena/images.ex index 313ab59f..f70c37a8 100644 --- a/lib/philomena/images.ex +++ b/lib/philomena/images.ex @@ -427,6 +427,7 @@ defmodule Philomena.Images do {:ok, result} -> reindex_image(duplicate_of_image) Comments.reindex_comments(duplicate_of_image) + notify_merge(image, duplicate_of_image) {:ok, result} @@ -742,6 +743,27 @@ defmodule Philomena.Images do {:ok, count} end + def notify_merge(source, target) do + spawn(fn -> + subscriptions = + target + |> Repo.preload(:subscriptions) + |> Map.fetch!(:subscriptions) + + Notifications.notify( + nil, + subscriptions, + %{ + actor_id: target.id, + actor_type: "Image", + actor_child_id: nil, + actor_child_type: nil, + action: "merged ##{source.id} into" + } + ) + end) + end + def clear_notification(_image, nil), do: nil def clear_notification(image, user) do