|> put_in(["object", "context"], context)
|> put_in(["object", "inReplyTo"], inReplyTo.data["object"]["id"])
|> put_in(["object", "inReplyToStatusId"], inReplyToId)
+ |> put_in(["statusnet_conversation_id"], inReplyTo.data["statusnet_conversation_id"])
+ |> put_in(["object", "statusnet_conversation_id"], inReplyTo.data["statusnet_conversation_id"])
else _e ->
activity
end
- ActivityPub.insert(activity)
+ with {:ok, activity} <- ActivityPub.insert(activity) do
+ add_conversation_id(activity)
+ end
end
def fetch_friend_statuses(user, opts \\ %{}) do
end
end
+ defp add_conversation_id(activity) do
+ if is_integer(activity.data["statusnet_conversation_id"]) do
+ {:ok, activity}
+ else
+ data = activity.data
+ |> put_in(["object", "statusnet_conversation_id"], activity.id)
+ |> put_in(["statusnet_conversation_id"], activity.id)
+
+ changeset = Ecto.Changeset.change(activity, data: data)
+ Repo.update(changeset)
+ end
+ end
+
defp activities_to_statuses(activities, opts) do
Enum.map(activities, fn(activity) ->
activity_to_status(activity, opts)
assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user))
assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
- # Add a context
+ # Add a context + 'statusnet_conversation_id'
assert is_binary(get_in(activity.data, ["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, ["statusnet_conversation_id"]) == activity.id
end
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, ["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, ["object", "statusnet_conversation_id"]) == get_in(activity.data, ["object", "statusnet_conversation_id"])
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
end