From 3f06ccc9e346fdf5278c19998170c968da930d17 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Tue, 14 Jun 2022 10:56:18 +0100 Subject: [PATCH] allow `source` from misskey --- .../article_note_page_validator.ex | 13 +++++++++++++ lib/pleroma/web/mastodon_api/views/status_view.ex | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex index e3f3110f2..118a10b09 100644 --- a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex @@ -29,6 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do end field(:replies, {:array, ObjectValidators.ObjectID}, default: []) + field(:source, :map) end def cast_and_apply(data) do @@ -79,6 +80,17 @@ defp fix_replies(%{"replies" => %{"first" => first}} = data) do defp fix_replies(data), do: data + # https://github.com/misskey-dev/misskey/pull/8787 + defp fix_misskey_content(%{"source" => %{"mediaType" => "text/x.misskeymarkdown"}} = object), do: object + + defp fix_misskey_content(%{"_misskey_content" => content} = object) do + object + |> Map.put("source", %{"content" => content, "mediaType" => "text/x.misskeymarkdown" }) + |> Map.delete("_misskey_content") + end + + defp fix_misskey_content(data), do: data + defp fix(data) do data |> CommonFixes.fix_actor() @@ -86,6 +98,7 @@ defp fix(data) do |> fix_url() |> fix_tag() |> fix_replies() + |> fix_misskey_content() |> Transmogrifier.fix_emoji() |> Transmogrifier.fix_content_map() end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 008040866..b3d742545 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -80,7 +80,6 @@ defp reblogged?(_activity, _user), do: false def render("index.json", opts) do reading_user = opts[:for] - # To do: check AdminAPIControllerTest on the reasons behind nil activities in the list activities = Enum.filter(opts.activities, & &1) @@ -329,7 +328,6 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} ) {pinned?, pinned_at} = pin_data(object, user) - %{ id: to_string(activity.id), uri: object.data["id"], @@ -376,6 +374,9 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} emoji_reactions: emoji_reactions, parent_visible: visible_for_user?(reply_to, opts[:for]), pinned_at: pinned_at + }, + akkoma: %{ + source: object.data["source"] } } end