mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
reject associated duplicate reports when deleting
This commit is contained in:
parent
31b1704847
commit
b18a1370a5
1 changed files with 6 additions and 0 deletions
|
@ -9,6 +9,7 @@ defmodule Philomena.Images do
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
|
|
||||||
alias Philomena.Elasticsearch
|
alias Philomena.Elasticsearch
|
||||||
|
alias Philomena.DuplicateReports.DuplicateReport
|
||||||
alias Philomena.Images.Image
|
alias Philomena.Images.Image
|
||||||
alias Philomena.Images.Hider
|
alias Philomena.Images.Hider
|
||||||
alias Philomena.Images.Uploader
|
alias Philomena.Images.Uploader
|
||||||
|
@ -323,6 +324,11 @@ defmodule Philomena.Images do
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide_image(%Image{} = image, user, attrs) do
|
def hide_image(%Image{} = image, user, attrs) do
|
||||||
|
DuplicateReport
|
||||||
|
|> where(state: "open")
|
||||||
|
|> where([d], d.image_id == ^image.id or d.duplicate_of_image_id == ^image.id)
|
||||||
|
|> Repo.update_all(set: [state: "rejected"])
|
||||||
|
|
||||||
Image.hide_changeset(image, attrs, user)
|
Image.hide_changeset(image, attrs, user)
|
||||||
|> internal_hide_image(image)
|
|> internal_hide_image(image)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue