mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
ensure subscriptions are carried over on merge
This commit is contained in:
parent
67832f623a
commit
ccc788a9da
1 changed files with 10 additions and 1 deletions
|
@ -415,6 +415,9 @@ defmodule Philomena.Images do
|
||||||
|> Multi.run(:migrate_comments, fn _, %{} ->
|
|> Multi.run(:migrate_comments, fn _, %{} ->
|
||||||
{:ok, Comments.migrate_comments(image, duplicate_of_image)}
|
{:ok, Comments.migrate_comments(image, duplicate_of_image)}
|
||||||
end)
|
end)
|
||||||
|
|> Multi.run(:migrate_subscriptions, fn _, %{} ->
|
||||||
|
{:ok, migrate_subscriptions(image, duplicate_of_image)}
|
||||||
|
end)
|
||||||
|> Multi.run(:migrate_interactions, fn _, %{} ->
|
|> Multi.run(:migrate_interactions, fn _, %{} ->
|
||||||
{:ok, Interactions.migrate_interactions(image, duplicate_of_image)}
|
{:ok, Interactions.migrate_interactions(image, duplicate_of_image)}
|
||||||
end)
|
end)
|
||||||
|
@ -706,7 +709,7 @@ defmodule Philomena.Images do
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Deletes a Subscription.
|
Deletes a subscription.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -724,6 +727,12 @@ defmodule Philomena.Images do
|
||||||
|> Repo.delete()
|
|> Repo.delete()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def migrate_subscriptions(source, target) do
|
||||||
|
Subscription
|
||||||
|
|> where(image_id: ^source.id)
|
||||||
|
|> Repo.update_all(set: [image_id: target.id])
|
||||||
|
end
|
||||||
|
|
||||||
def clear_notification(_image, nil), do: nil
|
def clear_notification(_image, nil), do: nil
|
||||||
|
|
||||||
def clear_notification(image, user) do
|
def clear_notification(image, user) do
|
||||||
|
|
Loading…
Reference in a new issue