Notification: Small refactor.

This commit is contained in:
lain 2020-08-31 11:02:54 +02:00
parent f0fefc4f5c
commit d91c4feebe
2 changed files with 3 additions and 3 deletions

View File

@ -649,8 +649,8 @@ def for_user_and_activity(user, activity) do
|> Repo.one() |> Repo.one()
end end
@spec mark_as_read(User.t(), Activity.t()) :: {integer(), nil | [term()]} @spec mark_context_as_read(User.t(), String.t()) :: {integer(), nil | [term()]}
def mark_as_read(%User{id: id}, %Activity{data: %{"context" => context}}) do def mark_context_as_read(%User{id: id}, context) do
from( from(
n in Notification, n in Notification,
join: a in assoc(n, :activity), join: a in assoc(n, :activity),

View File

@ -453,7 +453,7 @@ def unpin(id, user) do
def add_mute(user, activity) do def add_mute(user, activity) do
with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]), with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]),
_ <- Pleroma.Notification.mark_as_read(user, activity) do _ <- Pleroma.Notification.mark_context_as_read(user, activity.data["context"]) do
{:ok, activity} {:ok, activity}
else else
{:error, _} -> {:error, dgettext("errors", "conversation is already muted")} {:error, _} -> {:error, dgettext("errors", "conversation is already muted")}