projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'fix-admin-api-scope' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
pleroma_api
/
controllers
/
mascot_controller.ex
diff --git
a/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex
b/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex
index 7f6a76c0e24b56906f30eec440e5256af7db02a7..8cf552b7e230d77816235588d4ea1d6f35844bd8 100644
(file)
--- a/
lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex
+++ b/
lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex
@@
-5,9
+5,15
@@
defmodule Pleroma.Web.PleromaAPI.MascotController do
use Pleroma.Web, :controller
defmodule Pleroma.Web.PleromaAPI.MascotController do
use Pleroma.Web, :controller
+ alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
+ plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action == :show)
+ plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action != :show)
+
+ plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug)
+
@doc "GET /api/v1/pleroma/mascot"
def show(%{assigns: %{user: user}} = conn, _params) do
json(conn, User.get_mascot(user))
@doc "GET /api/v1/pleroma/mascot"
def show(%{assigns: %{user: user}} = conn, _params) do
json(conn, User.get_mascot(user))
@@
-18,9
+24,7
@@
defmodule Pleroma.Web.PleromaAPI.MascotController do
with {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)),
# Reject if not an image
%{type: "image"} = attachment <- render_attachment(object) do
with {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)),
# Reject if not an image
%{type: "image"} = attachment <- render_attachment(object) do
- # Sure!
- # Save to the user's info
- {:ok, _user} = User.update_info(user, &User.Info.mascot_update(&1, attachment))
+ {:ok, _user} = User.mascot_update(user, attachment)
json(conn, attachment)
else
json(conn, attachment)
else