add API routes to whitelist/unwhitelist
This commit is contained in:
parent
f741f79256
commit
686174897b
|
@ -55,6 +55,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
muting: User.mutes?(user, target),
|
||||
muting_notifications: User.muted_notifications?(user, target),
|
||||
subscribing: User.subscribed_to?(user, target),
|
||||
whitelisting: User.whitelists?(user, target),
|
||||
requested: requested,
|
||||
domain_blocking: User.blocks_domain?(user, target),
|
||||
showing_reblogs: User.showing_reblogs?(user, target),
|
||||
|
|
|
@ -43,7 +43,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
|
|||
)
|
||||
|
||||
plug(RateLimiter, [name: :account_confirmation_resend] when action == :confirmation_resend)
|
||||
plug(:assign_account_by_id when action in [:favourites, :subscribe, :unsubscribe])
|
||||
plug(:assign_account_by_id when action in [:favourites, :subscribe, :unsubscribe, :whitelist, :unwhitelist])
|
||||
plug(:put_view, Pleroma.Web.MastodonAPI.AccountView)
|
||||
|
||||
@doc "POST /api/v1/pleroma/accounts/confirmation_resend"
|
||||
|
@ -159,4 +159,22 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
|
|||
{:error, message} -> json_response(conn, :forbidden, %{error: message})
|
||||
end
|
||||
end
|
||||
|
||||
@doc "POST /api/v1/pleroma/accounts/:id/whitelist"
|
||||
def whitelist(%{assigns: %{user: user, account: whitelist_target}} = conn, _params) do
|
||||
with {:ok, user} <- User.whitelist(user, whitelist_target) do
|
||||
render(conn, "relationship.json", user: user, target: whitelist_target)
|
||||
else
|
||||
{:error, message} -> json_response(conn, :forbidden, %{error: message})
|
||||
end
|
||||
end
|
||||
|
||||
@doc "POST /api/v1/pleroma/accounts/:id/unwhitelist"
|
||||
def unwhitelist(%{assigns: %{user: user, account: whitelist_target}} = conn, _params) do
|
||||
with {:ok, user} <- User.unwhitelist(user, whitelist_target) do
|
||||
render(conn, "relationship.json", user: user, target: whitelist_target)
|
||||
else
|
||||
{:error, message} -> json_response(conn, :forbidden, %{error: message})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -310,6 +310,8 @@ defmodule Pleroma.Web.Router do
|
|||
|
||||
post("/accounts/:id/subscribe", AccountController, :subscribe)
|
||||
post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
|
||||
post("/accounts/:id/whitelist", AccountController, :whitelist)
|
||||
post("/accounts/:id/unwhitelist", AccountController, :unwhitelist)
|
||||
end
|
||||
|
||||
post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
|
||||
|
|
Loading…
Reference in New Issue