Merge branch 'bugfix/peertube-mpegURL-object' into 'develop'
Video: Handle peertube videos only stashing attachments in x-mpegURL Closes #2372 and #2535 See merge request pleroma/pleroma!3336
This commit is contained in:
commit
050c4b1f14
5 changed files with 596 additions and 9 deletions
|
|
@ -70,19 +70,33 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AudioVideoValidator do
|
|||
|> changeset(data)
|
||||
end
|
||||
|
||||
defp fix_url(%{"url" => url} = data) when is_list(url) do
|
||||
attachment =
|
||||
Enum.find(url, fn x ->
|
||||
mime_type = x["mimeType"] || x["mediaType"] || ""
|
||||
defp find_attachment(url) do
|
||||
mpeg_url =
|
||||
Enum.find(url, fn
|
||||
%{"mediaType" => mime_type, "tag" => tags} when is_list(tags) ->
|
||||
mime_type == "application/x-mpegURL"
|
||||
|
||||
is_map(x) and String.starts_with?(mime_type, ["video/", "audio/"])
|
||||
_ ->
|
||||
false
|
||||
end)
|
||||
|
||||
link_element =
|
||||
Enum.find(url, fn x ->
|
||||
mime_type = x["mimeType"] || x["mediaType"] || ""
|
||||
url
|
||||
|> Enum.concat(mpeg_url["tag"] || [])
|
||||
|> Enum.find(fn
|
||||
%{"mediaType" => mime_type} -> String.starts_with?(mime_type, ["video/", "audio/"])
|
||||
%{"mimeType" => mime_type} -> String.starts_with?(mime_type, ["video/", "audio/"])
|
||||
_ -> false
|
||||
end)
|
||||
end
|
||||
|
||||
is_map(x) and mime_type == "text/html"
|
||||
defp fix_url(%{"url" => url} = data) when is_list(url) do
|
||||
attachment = find_attachment(url)
|
||||
|
||||
link_element =
|
||||
Enum.find(url, fn
|
||||
%{"mediaType" => "text/html"} -> true
|
||||
%{"mimeType" => "text/html"} -> true
|
||||
_ -> false
|
||||
end)
|
||||
|
||||
data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue