{poll, poll_emoji} <- make_poll_data(data),
{to, cc} <-
get_to_and_cc(user, addressed_users, in_reply_to, visibility, in_reply_to_conversation),
- context <- make_context(in_reply_to),
+ context <- make_context(in_reply_to, in_reply_to_conversation),
cw <- data["spoiler_text"] || "",
sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
full_payload <- String.trim(status <> cw),
defp maybe_add_nsfw_tag(data, _), do: data
- def make_context(%Activity{data: %{"context" => context}}), do: context
- def make_context(_), do: Utils.generate_context_id()
+ def make_context(_, %Participation{} = participation) do
+ Repo.preload(participation, :conversation).conversation.ap_id
+ end
+
+ def make_context(%Activity{data: %{"context" => context}}, _), do: context
+ def make_context(_, _), do: Utils.generate_context_id()
def maybe_add_attachments(parsed, _attachments, true = _no_links), do: parsed
alias Pleroma.Object
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
+ test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
+ user = insert(:user)
+ {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+
+ [participation] = Participation.for_user(user)
+
+ {:ok, convo_reply} =
+ CommonAPI.post(user, %{"status" => ".", "in_reply_to_conversation_id" => participation.id})
+
+ assert Visibility.is_direct?(convo_reply)
+
+ assert activity.data["context"] == convo_reply.data["context"]
+ end
+
test "when replying to a conversation / participation, it only mentions the recipients explicitly declared in the participation" do
har = insert(:user)
jafnhar = insert(:user)