- def post(user, %{"status" => status} = data) do
- limit = Pleroma.Config.get([:instance, :limit])
-
- with status <- String.trim(status),
- attachments <- attachments_from_ids(data),
- in_reply_to <- get_replied_to_activity(data["in_reply_to_status_id"]),
- {visibility, in_reply_to_visibility} <- get_visibility(data, in_reply_to),
- {_, false} <-
- {:private_to_public, in_reply_to_visibility == "direct" && visibility != "direct"},
- {content_html, mentions, tags} <-
- make_content_html(
- status,
- attachments,
- data,
- visibility
- ),
- mentioned_users <- for({_, mentioned_user} <- mentions, do: mentioned_user.ap_id),
- addressed_users <- get_addressed_users(mentioned_users, data["to"]),
- {poll, poll_emoji} <- make_poll_data(data),
- {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),
- cw <- data["spoiler_text"] || "",
- sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
- full_payload <- String.trim(status <> cw),
- length when length in 1..limit <- String.length(full_payload),
- object <-
- make_note_data(
- user.ap_id,
- to,
- context,
- content_html,
- attachments,
- in_reply_to,
- tags,
- cw,
- cc,
- sensitive,
- poll
- ),
- object <-
- Map.put(
- object,
- "emoji",
- Map.merge(Formatter.get_emoji_map(full_payload), poll_emoji)
- ) do
- ActivityPub.create(
- %{
- to: to,
- actor: user,
- context: context,
- object: object,
- additional: %{"cc" => cc, "bcc" => bcc, "directMessage" => visibility == "direct"}
- },
- Pleroma.Web.ControllerHelper.truthy_param?(data["preview"]) || false
- )