forked from AkkomaGang/akkoma
Return statusnet_conversation_id in TwAPI.
This commit is contained in:
parent
e25aea3fa7
commit
0dd3373304
4 changed files with 15 additions and 12 deletions
|
@ -15,7 +15,8 @@ def to_map(%Activity{} = activity, %{user: user} = opts) do
|
||||||
"is_local" => true,
|
"is_local" => true,
|
||||||
"is_post_verb" => true,
|
"is_post_verb" => true,
|
||||||
"created_at" => published,
|
"created_at" => published,
|
||||||
"in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"]
|
"in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"],
|
||||||
|
"statusnet_conversation_id" => activity.data["object"]["statusnetConversationId"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,8 +34,8 @@ def create_status(user = %User{}, data = %{}) do
|
||||||
|> put_in(["object", "context"], context)
|
|> put_in(["object", "context"], context)
|
||||||
|> put_in(["object", "inReplyTo"], inReplyTo.data["object"]["id"])
|
|> put_in(["object", "inReplyTo"], inReplyTo.data["object"]["id"])
|
||||||
|> put_in(["object", "inReplyToStatusId"], inReplyToId)
|
|> put_in(["object", "inReplyToStatusId"], inReplyToId)
|
||||||
|> put_in(["statusnet_conversation_id"], inReplyTo.data["statusnet_conversation_id"])
|
|> put_in(["statusnetConversationId"], inReplyTo.data["statusnetConversationId"])
|
||||||
|> put_in(["object", "statusnet_conversation_id"], inReplyTo.data["statusnet_conversation_id"])
|
|> put_in(["object", "statusnetConversationId"], inReplyTo.data["statusnetConversationId"])
|
||||||
else _e ->
|
else _e ->
|
||||||
activity
|
activity
|
||||||
end
|
end
|
||||||
|
@ -72,12 +72,12 @@ def unfollow(%User{} = follower, followed_id) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_conversation_id(activity) do
|
defp add_conversation_id(activity) do
|
||||||
if is_integer(activity.data["statusnet_conversation_id"]) do
|
if is_integer(activity.data["statusnetConversationId"]) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
data = activity.data
|
data = activity.data
|
||||||
|> put_in(["object", "statusnet_conversation_id"], activity.id)
|
|> put_in(["object", "statusnetConversationId"], activity.id)
|
||||||
|> put_in(["statusnet_conversation_id"], activity.id)
|
|> put_in(["statusnetConversationId"], activity.id)
|
||||||
|
|
||||||
changeset = Ecto.Changeset.change(activity, data: data)
|
changeset = Ecto.Changeset.change(activity, data: data)
|
||||||
Repo.update(changeset)
|
Repo.update(changeset)
|
||||||
|
|
|
@ -24,7 +24,8 @@ test "an activity" do
|
||||||
"published" => date,
|
"published" => date,
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"content" => content,
|
"content" => content,
|
||||||
"inReplyToStatusId" => 213123
|
"inReplyToStatusId" => 213123,
|
||||||
|
"statusnetConversationId" => 4711
|
||||||
},
|
},
|
||||||
"published" => date
|
"published" => date
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,8 @@ test "an activity" do
|
||||||
"text" => content,
|
"text" => content,
|
||||||
"is_post_verb" => true,
|
"is_post_verb" => true,
|
||||||
"created_at" => date,
|
"created_at" => date,
|
||||||
"in_reply_to_status_id" => 213123
|
"in_reply_to_status_id" => 213123,
|
||||||
|
"statusnet_conversation_id" => 4711
|
||||||
}
|
}
|
||||||
|
|
||||||
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower}) == expected_status
|
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower}) == expected_status
|
||||||
|
|
|
@ -22,8 +22,8 @@ test "create a status" do
|
||||||
# Add a context + 'statusnet_conversation_id'
|
# Add a context + 'statusnet_conversation_id'
|
||||||
assert is_binary(get_in(activity.data, ["context"]))
|
assert is_binary(get_in(activity.data, ["context"]))
|
||||||
assert is_binary(get_in(activity.data, ["object", "context"]))
|
assert is_binary(get_in(activity.data, ["object", "context"]))
|
||||||
assert get_in(activity.data, ["object", "statusnet_conversation_id"]) == activity.id
|
assert get_in(activity.data, ["object", "statusnetConversationId"]) == activity.id
|
||||||
assert get_in(activity.data, ["statusnet_conversation_id"]) == activity.id
|
assert get_in(activity.data, ["statusnetConversationId"]) == activity.id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "create a status that is a reply" do
|
test "create a status that is a reply" do
|
||||||
|
@ -43,8 +43,8 @@ test "create a status that is a reply" do
|
||||||
|
|
||||||
assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"])
|
assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"])
|
||||||
assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
|
assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
|
||||||
assert get_in(reply.data, ["statusnet_conversation_id"]) == get_in(activity.data, ["statusnet_conversation_id"])
|
assert get_in(reply.data, ["statusnetConversationId"]) == get_in(activity.data, ["statusnetConversationId"])
|
||||||
assert get_in(reply.data, ["object", "statusnet_conversation_id"]) == get_in(activity.data, ["object", "statusnet_conversation_id"])
|
assert get_in(reply.data, ["object", "statusnetConversationId"]) == get_in(activity.data, ["object", "statusnetConversationId"])
|
||||||
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
||||||
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
|
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue