X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fobject_validators%2Faudio_video_validator.ex;h=4a96fef529899be4e80ac8c606df1b2dcbe15488;hb=9cc8642b80a3eceac405751a9c6b0be8e55db56d;hp=16973e5db740e28777507aa858e777f96b5843f9;hpb=59680f27ff0e1da2eb3c0506e3655f5c7b86a7ec;p=akkoma
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 16973e5db..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
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AudioVideoValidator do
@@ -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