From 8e02fa100f9f207253a35fbfd92e6e8f9b585435 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 18 May 2017 18:18:27 +0200 Subject: [PATCH] Add categories to ostatus output. --- lib/pleroma/web/ostatus/activity_representer.ex | 5 ++++- test/support/factory.ex | 3 ++- test/web/ostatus/activity_representer_test.exs | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index 02d15ea94..ccf71218c 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -42,6 +42,9 @@ def to_simple_form(%{data: %{"object" => %{"type" => "Note"}}} = activity, user, author = if with_author, do: [{:author, UserRepresenter.to_simple_form(user)}], else: [] mentions = activity.data["to"] |> get_mentions + categories = (activity.data["object"]["tag"] || []) + |> Enum.map(fn (tag) -> {:category, [term: to_charlist(tag)], []} end) + [ {:"activity:object-type", ['http://activitystrea.ms/schema/1.0/note']}, {:"activity:verb", ['http://activitystrea.ms/schema/1.0/post']}, @@ -53,7 +56,7 @@ def to_simple_form(%{data: %{"object" => %{"type" => "Note"}}} = activity, user, {:"ostatus:conversation", [], h.(activity.data["context"])}, {:link, [href: h.(activity.data["context"]), rel: 'ostatus:conversation'], []}, {:link, [type: ['application/atom+xml'], href: h.(activity.data["object"]["id"]), rel: 'self'], []} - ] ++ attachments ++ in_reply_to ++ author ++ mentions + ] ++ categories ++ attachments ++ in_reply_to ++ author ++ mentions end def to_simple_form(%{data: %{"type" => "Like"}} = activity, user, with_author) do diff --git a/test/support/factory.ex b/test/support/factory.ex index ffc9c56dc..3cf35e3bc 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -25,7 +25,8 @@ def note_factory do "published_at" => DateTime.utc_now() |> DateTime.to_iso8601, "likes" => [], "like_count" => 0, - "context" => "2hu" + "context" => "2hu", + "tag" => ["2hu"] } %Pleroma.Object{ diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 969b2a854..7179cfb71 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -27,6 +27,7 @@ test "a note activity" do #{note_activity.data["context"]} + """