diff options
author | lain <lain@soykaf.club> | 2021-02-28 16:18:23 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2021-02-28 16:18:23 +0000 |
commit | 050c4b1f145fabac4347bc670a15b1d125882bd5 (patch) | |
tree | 6b47fa6d592d9a4509787982b0c3669b6b816132 /lib | |
parent | e6a14e1cd10a52450eaf3d1ba258eac4042d82a9 (diff) | |
parent | 7fc9cd09740e31fe75ff3402f29614bb328240f7 (diff) | |
download | pleroma-050c4b1f145fabac4347bc670a15b1d125882bd5.tar.gz pleroma-050c4b1f145fabac4347bc670a15b1d125882bd5.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex b/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex index b3e738d8d..4a96fef52 100644 --- a/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex @@ -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"] || "" - - is_map(x) and String.starts_with?(mime_type, ["video/", "audio/"]) + 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" + + _ -> + 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 |