if using local media, the mediaproxy will not replace the URL anyway.
def render("attachment.json", %{attachment: attachment}) do
[attachment_url | _] = attachment["url"]
media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image"
def render("attachment.json", %{attachment: attachment}) do
[attachment_url | _] = attachment["url"]
media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image"
- href = attachment_url["href"]
+ href = attachment_url["href"] |> MediaProxy.url()
%{
id: to_string(attachment["id"] || hash_id),
%{
id: to_string(attachment["id"] || hash_id),
- url: MediaProxy.url(href),
- preview_url: MediaProxy.url(href),
text_url: href,
type: type,
description: attachment["name"]
text_url: href,
type: type,
description: attachment["name"]
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.{OStatus, CommonAPI}
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.{OStatus, CommonAPI}
+ alias Pleroma.Web.MediaProxy
import Ecto.Query
@instance Application.get_env(:pleroma, :instance)
import Ecto.Query
@instance Application.get_env(:pleroma, :instance)
{:ok, object} = ActivityPub.upload(file)
url = List.first(object.data["url"])
{:ok, object} = ActivityPub.upload(file)
url = List.first(object.data["url"])
+ href = url["href"] |> MediaProxy.url()
type = url["mediaType"]
case format do
type = url["mediaType"]
case format do