2019-08-05 07:09:19 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 15:44:49 -07:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-08-05 07:09:19 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.MastodonAPI.ConversationViewTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
|
|
|
alias Pleroma.Conversation.Participation
|
2019-08-05 08:11:23 -06:00
|
|
|
alias Pleroma.Web.CommonAPI
|
2019-08-05 07:09:19 -06:00
|
|
|
alias Pleroma.Web.MastodonAPI.ConversationView
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
test "represents a Mastodon Conversation entity" do
|
|
|
|
user = insert(:user)
|
|
|
|
other_user = insert(:user)
|
|
|
|
|
2020-06-15 04:27:13 -06:00
|
|
|
{:ok, parent} = CommonAPI.post(user, %{status: "parent"})
|
|
|
|
|
2019-08-05 07:09:19 -06:00
|
|
|
{:ok, activity} =
|
2020-06-15 04:27:13 -06:00
|
|
|
CommonAPI.post(user, %{
|
|
|
|
status: "hey @#{other_user.nickname}",
|
|
|
|
visibility: "direct",
|
|
|
|
in_reply_to_id: parent.id
|
|
|
|
})
|
|
|
|
|
|
|
|
{:ok, _reply_activity} =
|
|
|
|
CommonAPI.post(user, %{status: "hu", visibility: "public", in_reply_to_id: parent.id})
|
2019-08-05 07:09:19 -06:00
|
|
|
|
|
|
|
[participation] = Participation.for_user_with_last_activity_id(user)
|
|
|
|
|
|
|
|
assert participation
|
|
|
|
|
|
|
|
conversation =
|
2019-08-12 06:23:06 -06:00
|
|
|
ConversationView.render("participation.json", %{participation: participation, for: user})
|
2019-08-05 07:09:19 -06:00
|
|
|
|
|
|
|
assert conversation.id == participation.id |> to_string()
|
|
|
|
assert conversation.last_status.id == activity.id
|
2020-10-30 06:37:15 -06:00
|
|
|
assert conversation.last_status.account.id == user.id
|
2019-08-05 07:09:19 -06:00
|
|
|
|
2020-10-18 13:12:42 -06:00
|
|
|
account_ids = Enum.map(conversation.accounts, & &1.id)
|
2020-10-30 06:37:15 -06:00
|
|
|
assert length(conversation.accounts) == 1
|
2020-10-18 10:01:17 -06:00
|
|
|
assert other_user.id in account_ids
|
2019-10-30 18:44:27 -06:00
|
|
|
assert conversation.last_status.pleroma.direct_conversation_id == participation.id
|
2019-08-05 07:09:19 -06:00
|
|
|
end
|
|
|
|
end
|