Refactor as per Rin's suggestions, add endpoint tests
This commit is contained in:
parent
cc21fc5f53
commit
c01ef574c1
9 changed files with 136 additions and 105 deletions
|
|
@ -446,7 +446,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
end
|
||||
|
||||
def mute_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||
with {:ok, activity} <- Pleroma.Web.ThreadMute.add_mute(user, id) do
|
||||
activity = Activity.get_by_id(id)
|
||||
with {:ok, activity} <- CommonAPI.add_mute(user, activity) do
|
||||
conn
|
||||
|> put_view(StatusView)
|
||||
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
|
||||
|
|
@ -459,7 +460,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
end
|
||||
|
||||
def unmute_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||
with {:ok, activity} <- Pleroma.Web.ThreadMute.remove_mute(user, id) do
|
||||
activity = Activity.get_by_id(id)
|
||||
with {:ok, activity} <- CommonAPI.remove_mute(user, activity) do
|
||||
conn
|
||||
|> put_view(StatusView)
|
||||
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
alias Pleroma.HTML
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.MediaProxy
|
||||
alias Pleroma.Web.MastodonAPI.AccountView
|
||||
|
|
@ -160,7 +161,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
reblogged: present?(repeated),
|
||||
favourited: present?(favorited),
|
||||
bookmarked: present?(bookmarked),
|
||||
muted: Pleroma.Web.ThreadMute.muted?(user, activity),
|
||||
muted: CommonAPI.thread_muted?(user, activity),
|
||||
pinned: pinned?(activity, user),
|
||||
sensitive: sensitive,
|
||||
spoiler_text: object["summary"] || "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue