Add "listMessage"
This commit is contained in:
parent
182f7bbb11
commit
958fb9aa80
|
@ -136,7 +136,6 @@ def publish(actor, %{data: %{"bcc" => bcc}} = activity) when is_list(bcc) and bc
|
||||||
json =
|
json =
|
||||||
data
|
data
|
||||||
|> Map.put("cc", cc)
|
|> Map.put("cc", cc)
|
||||||
|> Map.put("directMessage", true)
|
|
||||||
|> Jason.encode!()
|
|> Jason.encode!()
|
||||||
|
|
||||||
Pleroma.Web.Federator.Publisher.enqueue_one(__MODULE__, %{
|
Pleroma.Web.Federator.Publisher.enqueue_one(__MODULE__, %{
|
||||||
|
|
|
@ -215,7 +215,6 @@ def post(user, %{"status" => status} = data) do
|
||||||
addressed_users <- get_addressed_users(mentioned_users, data["to"]),
|
addressed_users <- get_addressed_users(mentioned_users, data["to"]),
|
||||||
{poll, poll_emoji} <- make_poll_data(data),
|
{poll, poll_emoji} <- make_poll_data(data),
|
||||||
{to, cc} <- get_to_and_cc(user, addressed_users, in_reply_to, visibility),
|
{to, cc} <- get_to_and_cc(user, addressed_users, in_reply_to, visibility),
|
||||||
bcc <- bcc_for_list(user, visibility),
|
|
||||||
context <- make_context(in_reply_to),
|
context <- make_context(in_reply_to),
|
||||||
cw <- data["spoiler_text"] || "",
|
cw <- data["spoiler_text"] || "",
|
||||||
sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
|
sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
|
||||||
|
@ -241,16 +240,21 @@ def post(user, %{"status" => status} = data) do
|
||||||
"emoji",
|
"emoji",
|
||||||
Map.merge(Formatter.get_emoji_map(full_payload), poll_emoji)
|
Map.merge(Formatter.get_emoji_map(full_payload), poll_emoji)
|
||||||
) do
|
) do
|
||||||
ActivityPub.create(
|
preview? = Pleroma.Web.ControllerHelper.truthy_param?(data["preview"]) || false
|
||||||
%{
|
direct? = visibility == "direct"
|
||||||
to: to,
|
|
||||||
actor: user,
|
additional_data =
|
||||||
context: context,
|
%{"cc" => cc, "directMessage" => direct?} |> maybe_add_list_data(user, visibility)
|
||||||
object: object,
|
|
||||||
additional: %{"cc" => cc, "bcc" => bcc, "directMessage" => visibility == "direct"}
|
params = %{
|
||||||
},
|
to: to,
|
||||||
Pleroma.Web.ControllerHelper.truthy_param?(data["preview"]) || false
|
actor: user,
|
||||||
)
|
context: context,
|
||||||
|
object: object,
|
||||||
|
additional: additional_data
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityPub.create(params, preview?)
|
||||||
else
|
else
|
||||||
{:private_to_public, true} ->
|
{:private_to_public, true} ->
|
||||||
{:error, dgettext("errors", "The message visibility must be direct")}
|
{:error, dgettext("errors", "The message visibility must be direct")}
|
||||||
|
|
|
@ -108,12 +108,19 @@ def get_addressed_users(_, to) when is_list(to) do
|
||||||
|
|
||||||
def get_addressed_users(mentioned_users, _), do: mentioned_users
|
def get_addressed_users(mentioned_users, _), do: mentioned_users
|
||||||
|
|
||||||
def bcc_for_list(user, {:list, list_id}) do
|
def maybe_add_list_data(additional_data, user, {:list, list_id}) do
|
||||||
list = Pleroma.List.get(list_id, user)
|
case Pleroma.List.get(list_id, user) do
|
||||||
[list.ap_id]
|
%Pleroma.List{} = list ->
|
||||||
|
additional_data
|
||||||
|
|> Map.put("listMessage", list.ap_id)
|
||||||
|
|> Map.put("bcc", [list.ap_id])
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
additional_data
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def bcc_for_list(_, _), do: []
|
def maybe_add_list_data(additional_data, _, _), do: additional_data
|
||||||
|
|
||||||
def make_poll_data(%{"poll" => %{"options" => options, "expires_in" => expires_in}} = data)
|
def make_poll_data(%{"poll" => %{"options" => options, "expires_in" => expires_in}} = data)
|
||||||
when is_list(options) do
|
when is_list(options) do
|
||||||
|
|
|
@ -139,6 +139,7 @@ test "it allows to address a list" do
|
||||||
|
|
||||||
assert activity.data["bcc"] == [list.ap_id]
|
assert activity.data["bcc"] == [list.ap_id]
|
||||||
assert activity.recipients == [list.ap_id, user.ap_id]
|
assert activity.recipients == [list.ap_id, user.ap_id]
|
||||||
|
assert activity.data["listMessage"] == list.ap_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue