mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
remove images from galleries when they are hidden (derpibooru/philomena#219)
This commit is contained in:
parent
9f9a4c1967
commit
f771f4a90f
1 changed files with 11 additions and 0 deletions
|
@ -27,6 +27,8 @@ defmodule Philomena.Images do
|
|||
alias Philomena.Reports
|
||||
alias Philomena.Reports.Report
|
||||
alias Philomena.Comments
|
||||
alias Philomena.Galleries.Gallery
|
||||
alias Philomena.Galleries.Interaction
|
||||
|
||||
@doc """
|
||||
Gets a single image.
|
||||
|
@ -422,9 +424,18 @@ defmodule Philomena.Images do
|
|||
|> select([r], r.id)
|
||||
|> update(set: [open: false, state: "closed", admin_id: ^user.id])
|
||||
|
||||
galleries =
|
||||
Gallery
|
||||
|> join(:inner, [g], gi in assoc(g, :interactions), on: gi.image_id == ^image.id)
|
||||
|> update(inc: [image_count: -1])
|
||||
|
||||
gallery_interactions = where(Interaction, image_id: ^image.id)
|
||||
|
||||
multi
|
||||
|> Multi.update(:image, changeset)
|
||||
|> Multi.update_all(:reports, reports, [])
|
||||
|> Multi.update_all(:galleries, galleries, [])
|
||||
|> Multi.delete_all(:gallery_interactions, gallery_interactions, [])
|
||||
|> Multi.run(:tags, fn repo, %{image: image} ->
|
||||
image = Repo.preload(image, :tags, force: true)
|
||||
|
||||
|
|
Loading…
Reference in a new issue