Add some twapi fixes.

This commit is contained in:
Roger Braun 2017-05-07 20:20:53 +02:00
parent e49770ee88
commit 7303786160
2 changed files with 8 additions and 2 deletions

View File

@ -29,7 +29,8 @@ def to_map(%Activity{data: %{"type" => "Announce", "actor" => actor, "published"
"uri" => "tag:#{activity.data["id"]}:objectType=note", "uri" => "tag:#{activity.data["id"]}:objectType=note",
"created_at" => created_at, "created_at" => created_at,
"retweeted_status" => retweeted_status, "retweeted_status" => retweeted_status,
"statusnet_conversation_id" => conversation_id(announced_activity) "statusnet_conversation_id" => conversation_id(announced_activity),
"external_url" => activity.data["id"]
} }
end end
@ -49,6 +50,7 @@ def to_map(%Activity{data: %{"type" => "Like", "published" => created_at}} = act
"uri" => "tag:#{activity.data["id"]}:objectType=Favourite", "uri" => "tag:#{activity.data["id"]}:objectType=Favourite",
"created_at" => created_at, "created_at" => created_at,
"in_reply_to_status_id" => liked_activity.id, "in_reply_to_status_id" => liked_activity.id,
"external_url" => activity.data["id"]
} }
end end
@ -67,6 +69,7 @@ def to_map(%Activity{data: %{"type" => "Follow", "published" => created_at, "obj
"is_post_verb" => false, "is_post_verb" => false,
"created_at" => created_at, "created_at" => created_at,
"in_reply_to_status_id" => nil, "in_reply_to_status_id" => nil,
"external_url" => activity.data["id"]
} }
end end
@ -103,6 +106,7 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac
"repeat_num" => announcement_count, "repeat_num" => announcement_count,
"favorited" => to_boolean(favorited), "favorited" => to_boolean(favorited),
"repeated" => to_boolean(repeated), "repeated" => to_boolean(repeated),
"external_url" => activity.data["id"]
} }
end end

View File

@ -77,6 +77,7 @@ test "an activity" do
id: 1, id: 1,
data: %{ data: %{
"type" => "Create", "type" => "Create",
"id" => "id",
"to" => [ "to" => [
User.ap_followers(user), User.ap_followers(user),
"https://www.w3.org/ns/activitystreams#Public", "https://www.w3.org/ns/activitystreams#Public",
@ -121,7 +122,8 @@ test "an activity" do
"fave_num" => 5, "fave_num" => 5,
"repeat_num" => 3, "repeat_num" => 3,
"favorited" => false, "favorited" => false,
"repeated" => false "repeated" => false,
"external_url" => activity.data["id"]
} }
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status