forked from AkkomaGang/akkoma
Add conversation ids to twapi announce representer.
This commit is contained in:
parent
c51e15975a
commit
95ab0dc3c5
2 changed files with 12 additions and 6 deletions
|
@ -27,7 +27,8 @@ def to_map(%Activity{data: %{"type" => "Announce", "actor" => actor, "published"
|
||||||
"is_post_verb" => false,
|
"is_post_verb" => false,
|
||||||
"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)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,11 +83,7 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac
|
||||||
|> Enum.filter(&(&1))
|
|> Enum.filter(&(&1))
|
||||||
|> Enum.map(fn (user) -> UserRepresenter.to_map(user, opts) end)
|
|> Enum.map(fn (user) -> UserRepresenter.to_map(user, opts) end)
|
||||||
|
|
||||||
|
conversation_id = conversation_id(activity)
|
||||||
conversation_id = with context when not is_nil(context) <- activity.data["context"] do
|
|
||||||
TwitterAPI.context_to_conversation_id(context)
|
|
||||||
else _e -> nil
|
|
||||||
end
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => activity.id,
|
"id" => activity.id,
|
||||||
|
@ -108,6 +105,13 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conversation_id(activity) do
|
||||||
|
with context when not is_nil(context) <- activity.data["context"] do
|
||||||
|
TwitterAPI.context_to_conversation_id(context)
|
||||||
|
else _e -> nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp date_to_asctime(date) do
|
defp date_to_asctime(date) do
|
||||||
with {:ok, date, _offset} <- date |> DateTime.from_iso8601 do
|
with {:ok, date, _offset} <- date |> DateTime.from_iso8601 do
|
||||||
Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y")
|
Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y")
|
||||||
|
|
|
@ -22,6 +22,8 @@ test "an announce activity" do
|
||||||
|
|
||||||
retweeted_status = ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user})
|
retweeted_status = ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user})
|
||||||
assert retweeted_status["repeated"] == true
|
assert retweeted_status["repeated"] == true
|
||||||
|
assert retweeted_status["id"] == note_activity.id
|
||||||
|
assert status["statusnet_conversation_id"] == retweeted_status["statusnet_conversation_id"]
|
||||||
|
|
||||||
assert status["retweeted_status"] == retweeted_status
|
assert status["retweeted_status"] == retweeted_status
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue