From: Egor Kislitsyn Date: Wed, 5 Jun 2019 10:53:15 +0000 (+0700) Subject: Merge remote-tracking branch 'pleroma/develop' into feature/addressable-lists X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=cfa5572d28a5a7b58d73106c32420b14ffd9fd2a;p=akkoma Merge remote-tracking branch 'pleroma/develop' into feature/addressable-lists --- cfa5572d28a5a7b58d73106c32420b14ffd9fd2a diff --cc docs/api/differences_in_mastoapi_responses.md index fd23fe2d2,f5766c2d9..fb77ce68d --- a/docs/api/differences_in_mastoapi_responses.md +++ b/docs/api/differences_in_mastoapi_responses.md @@@ -70,7 -70,7 +70,8 @@@ Additional parameters can be added to t - `preview`: boolean, if set to `true` the post won't be actually posted, but the status entitiy would still be rendered back. This could be useful for previewing rich text/custom emoji, for example. - `content_type`: string, contain the MIME type of the status, it is transformed into HTML by the backend. You can get the list of the supported MIME types with the nodeinfo endpoint. + - `to`: A list of nicknames (like `lain@soykaf.club` or `lain` on the local server) that will be used to determine who is going to be addressed by this post. Using this will disable the implicit addressing by mentioned names in the `status` body, only the people in the `to` list will be addressed. The normal rules for for post visibility are not affected by this and will still apply. +- `visibility`: string, besides standard MastoAPI values (`direct`, `private`, `unlisted` or `public`) it can be used to address a List by setting it to `list:LIST_ID`. ## PATCH `/api/v1/update_credentials` diff --cc lib/pleroma/web/common_api/common_api.ex index 536058666,2b3ae3de5..25b5fedb8 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@@ -209,9 -204,10 +209,11 @@@ defmodule Pleroma.Web.CommonAPI d 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} <- to_for_user_and_mentions(user, mentions, 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), cw <- data["spoiler_text"] || "", sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}), diff --cc lib/pleroma/web/common_api/utils.ex index 9c92c6cea,6d82c0bd2..22ce1ea90 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@@ -102,15 -98,12 +98,19 @@@ defmodule Pleroma.Web.CommonAPI.Utils d end end - def to_for_user_and_mentions(_user, _mentions, _inReplyTo, _), do: {[], []} + def get_addressed_users(_, to) when is_list(to) do + User.get_ap_ids_by_nicknames(to) + end + + def get_addressed_users(mentioned_users, _), do: mentioned_users + def bcc_for_list(user, {:list, list_id}) do + list = Pleroma.List.get(list_id, user) + [list.ap_id] + end + + def bcc_for_list(_, _), do: [] + def make_poll_data(%{"poll" => %{"options" => options, "expires_in" => expires_in}} = data) when is_list(options) do %{max_expiration: max_expiration, min_expiration: min_expiration} =