mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-14 05:04:49 +00:00
twitter/mastodon api: always use mediaproxy URLs in attachments
if using local media, the mediaproxy will not replace the URL anyway.
This commit is contained in:
parent
658036881d
commit
5c6ec2d9fc
2 changed files with 5 additions and 4 deletions
|
@ -166,7 +166,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
def render("attachment.json", %{attachment: attachment}) do
|
def render("attachment.json", %{attachment: attachment}) do
|
||||||
[attachment_url | _] = attachment["url"]
|
[attachment_url | _] = attachment["url"]
|
||||||
media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image"
|
media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image"
|
||||||
href = attachment_url["href"]
|
href = attachment_url["href"] |> MediaProxy.url()
|
||||||
|
|
||||||
type =
|
type =
|
||||||
cond do
|
cond do
|
||||||
|
@ -180,9 +180,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
|
|
||||||
%{
|
%{
|
||||||
id: to_string(attachment["id"] || hash_id),
|
id: to_string(attachment["id"] || hash_id),
|
||||||
url: MediaProxy.url(href),
|
url: href,
|
||||||
remote_url: href,
|
remote_url: href,
|
||||||
preview_url: MediaProxy.url(href),
|
preview_url: href,
|
||||||
text_url: href,
|
text_url: href,
|
||||||
type: type,
|
type: type,
|
||||||
description: attachment["name"]
|
description: attachment["name"]
|
||||||
|
|
|
@ -3,6 +3,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.TwitterAPI.UserView
|
alias Pleroma.Web.TwitterAPI.UserView
|
||||||
alias Pleroma.Web.{OStatus, CommonAPI}
|
alias Pleroma.Web.{OStatus, CommonAPI}
|
||||||
|
alias Pleroma.Web.MediaProxy
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
@instance Application.get_env(:pleroma, :instance)
|
@instance Application.get_env(:pleroma, :instance)
|
||||||
|
@ -97,7 +98,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
{:ok, object} = ActivityPub.upload(file)
|
{:ok, object} = ActivityPub.upload(file)
|
||||||
|
|
||||||
url = List.first(object.data["url"])
|
url = List.first(object.data["url"])
|
||||||
href = url["href"]
|
href = url["href"] |> MediaProxy.url()
|
||||||
type = url["mediaType"]
|
type = url["mediaType"]
|
||||||
|
|
||||||
case format do
|
case format do
|
||||||
|
|
Loading…
Reference in a new issue