only link in content field
Some checks failed
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/pr/release Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline failed
ci/woodpecker/pr/test Pipeline was successful

This commit is contained in:
FloatingGhost 2022-07-10 17:47:24 +01:00
parent 838b025337
commit e71a7893ec
2 changed files with 13 additions and 4 deletions

View file

@ -86,7 +86,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
%{"source" => %{"mediaType" => "text/x.misskeymarkdown", "content" => content}} = object %{"source" => %{"mediaType" => "text/x.misskeymarkdown", "content" => content}} = object
) do ) do
{linked, _, _} = Utils.format_input(content, "text/x.misskeymarkdown") {linked, _, _} = Utils.format_input(content, "text/x.misskeymarkdown")
put_in(object, ["source", "content"], linked) Map.put(object, "content", linked)
end end
defp fix_misskey_content(%{"_misskey_content" => content} = object) do defp fix_misskey_content(%{"_misskey_content" => content} = object) do
@ -94,9 +94,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
object object
|> Map.put("source", %{ |> Map.put("source", %{
"content" => linked, "content" => content,
"mediaType" => "text/x.misskeymarkdown" "mediaType" => "text/x.misskeymarkdown"
}) })
|> Map.put("content", linked)
|> Map.delete("_misskey_content") |> Map.delete("_misskey_content")
end end

View file

@ -86,7 +86,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
%{ %{
valid?: true, valid?: true,
changes: %{ changes: %{
source: %{"content" => ^expected_content, "mediaType" => "text/x.misskeymarkdown"} content: ^expected_content,
source: %{
"content" => "@akkoma_user linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa",
"mediaType" => "text/x.misskeymarkdown"
}
} }
} = ArticleNotePageValidator.cast_and_validate(note) } = ArticleNotePageValidator.cast_and_validate(note)
end end
@ -107,7 +111,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
%{ %{
valid?: true, valid?: true,
changes: %{ changes: %{
source: %{"content" => ^expected_content, "mediaType" => "text/x.misskeymarkdown"} content: ^expected_content,
source: %{
"content" => "@akkoma_user linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa",
"mediaType" => "text/x.misskeymarkdown"
}
} }
} = ArticleNotePageValidator.cast_and_validate(note) } = ArticleNotePageValidator.cast_and_validate(note)
end end