diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-11-19 23:22:10 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-11-19 23:22:10 +0300 |
commit | ba5cc3016514080b4bf7eaefd3e25936c0e222ba (patch) | |
tree | 799e826ee738487fcf758fd966cff263f8b491db /lib/pleroma/web/mastodon_api/controllers | |
parent | 3aaf3aa2c24c6b38d7e49e4861c1294c285db49b (diff) | |
download | pleroma-ba5cc3016514080b4bf7eaefd3e25936c0e222ba.tar.gz |
[#1335] Implemented notification mutes and reblog mutes as UserRelationships. User to UserRelationship relations and functions refactoring.
Diffstat (limited to 'lib/pleroma/web/mastodon_api/controllers')
-rw-r--r-- | lib/pleroma/web/mastodon_api/controllers/account_controller.ex | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index 750f5c690..5b6158b93 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -323,9 +323,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do def mute(%{assigns: %{user: muter, account: muted}} = conn, params) do notifications? = params |> Map.get("notifications", true) |> truthy_param?() - with {:ok, _user_mute} <- User.mute(muter, muted, notifications?) do - # TODO: remove `muter` refresh once `muted_notifications` field is deprecated - muter = User.get_cached_by_id(muter.id) + with {:ok, _user_relationships} <- User.mute(muter, muted, notifications?) do render(conn, "relationship.json", user: muter, target: muted) else {:error, message} -> json_response(conn, :forbidden, %{error: message}) @@ -334,9 +332,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do @doc "POST /api/v1/accounts/:id/unmute" def unmute(%{assigns: %{user: muter, account: muted}} = conn, _params) do - with {:ok, _user_mute} <- User.unmute(muter, muted) do - # TODO: remove `muter` refresh once `muted_notifications` field is deprecated - muter = User.get_cached_by_id(muter.id) + with {:ok, _user_relationships} <- User.unmute(muter, muted) do render(conn, "relationship.json", user: muter, target: muted) else {:error, message} -> json_response(conn, :forbidden, %{error: message}) @@ -377,12 +373,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do @doc "GET /api/v1/mutes" def mutes(%{assigns: %{user: user}} = conn, _) do - render(conn, "index.json", users: User.muted_users(user), for: user, as: :user) + users = User.muted_users(user, _restrict_deactivated = true) + render(conn, "index.json", users: users, for: user, as: :user) end @doc "GET /api/v1/blocks" def blocks(%{assigns: %{user: user}} = conn, _) do - render(conn, "index.json", users: User.blocked_users(user), for: user, as: :user) + users = User.blocked_users(user, _restrict_deactivated = true) + render(conn, "index.json", users: users, for: user, as: :user) end @doc "GET /api/v1/endorsements" |