re-add merge notification

This commit is contained in:
byte[] 2020-09-09 22:47:35 -04:00
parent ea424ac83b
commit 11276b2339

View file

@ -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