mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Fix gallery deletion
This commit is contained in:
parent
c7f618d9dd
commit
91e1af6402
1 changed files with 0 additions and 14 deletions
|
@ -15,7 +15,6 @@ defmodule Philomena.Galleries do
|
||||||
alias Philomena.GalleryReorderWorker
|
alias Philomena.GalleryReorderWorker
|
||||||
alias Philomena.Notifications
|
alias Philomena.Notifications
|
||||||
alias Philomena.NotificationWorker
|
alias Philomena.NotificationWorker
|
||||||
alias Philomena.Notifications.{Notification, UnreadNotification}
|
|
||||||
alias Philomena.Images
|
alias Philomena.Images
|
||||||
|
|
||||||
use Philomena.Subscriptions,
|
use Philomena.Subscriptions,
|
||||||
|
@ -95,21 +94,8 @@ defmodule Philomena.Galleries do
|
||||||
|> select([i], i.image_id)
|
|> select([i], i.image_id)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
unread_notifications =
|
|
||||||
UnreadNotification
|
|
||||||
|> join(:inner, [un], _ in assoc(un, :notification))
|
|
||||||
|> where([_, n], n.actor_type == "Gallery")
|
|
||||||
|> where([_, n], n.actor_id == ^gallery.id)
|
|
||||||
|
|
||||||
notifications =
|
|
||||||
Notification
|
|
||||||
|> where(actor_type: "Gallery")
|
|
||||||
|> where(actor_id: ^gallery.id)
|
|
||||||
|
|
||||||
Multi.new()
|
Multi.new()
|
||||||
|> Multi.delete(:gallery, gallery)
|
|> Multi.delete(:gallery, gallery)
|
||||||
|> Multi.delete_all(:unread_notifications, unread_notifications)
|
|
||||||
|> Multi.delete_all(:notifications, notifications)
|
|
||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, %{gallery: gallery}} ->
|
{:ok, %{gallery: gallery}} ->
|
||||||
|
|
Loading…
Reference in a new issue