[#210] Mastodon: actor storing for media uploads, ownership check to update_media.
Refactoring.
This commit is contained in:
parent
3b5be09f45
commit
3e90f688f1
6 changed files with 38 additions and 27 deletions
|
|
@ -93,12 +93,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
end
|
||||
end
|
||||
|
||||
def ap_upload(%Plug.Upload{} = file, %User{} = user) do
|
||||
ActivityPub.upload(file, actor: User.ap_id(user))
|
||||
end
|
||||
|
||||
def upload(%Plug.Upload{} = file, %User{} = user, format \\ "xml") do
|
||||
{:ok, object} = ap_upload(file, user)
|
||||
{:ok, object} = ActivityPub.upload(file, actor: User.ap_id(user))
|
||||
|
||||
url = List.first(object.data["url"])
|
||||
href = url["href"]
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
!object ->
|
||||
{halt(conn), :not_found, ""}
|
||||
|
||||
object.data["actor"] != User.ap_id(user) ->
|
||||
!Object.authorize_mutation(object, user) ->
|
||||
{halt(conn), :forbidden, "You can only update your own uploads."}
|
||||
|
||||
!is_binary(description) ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue