marks notifications as read after mute
This commit is contained in:
parent
51844b1e42
commit
f0fefc4f5c
3 changed files with 79 additions and 1 deletions
|
|
@ -648,4 +648,16 @@ defmodule Pleroma.Notification do
|
|||
)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
@spec mark_as_read(User.t(), Activity.t()) :: {integer(), nil | [term()]}
|
||||
def mark_as_read(%User{id: id}, %Activity{data: %{"context" => context}}) do
|
||||
from(
|
||||
n in Notification,
|
||||
join: a in assoc(n, :activity),
|
||||
where: n.user_id == ^id,
|
||||
where: n.seen == false,
|
||||
where: fragment("?->>'context'", a.data) == ^context
|
||||
)
|
||||
|> Repo.update_all(set: [seen: true])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -452,7 +452,8 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
end
|
||||
|
||||
def add_mute(user, activity) do
|
||||
with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]) do
|
||||
with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]),
|
||||
_ <- Pleroma.Notification.mark_as_read(user, activity) do
|
||||
{:ok, activity}
|
||||
else
|
||||
{:error, _} -> {:error, dgettext("errors", "conversation is already muted")}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue