CommonAPI: Add explicit addressing.
[akkoma] / lib / pleroma / web / common_api / common_api.ex
index a12ee011bef12711c75ce0871ec60f700fcb4063..f5f62eee351fb641a4387871eff00ffbab08c980 100644 (file)
@@ -144,7 +144,7 @@ defmodule Pleroma.Web.CommonAPI do
       object = Object.get_cached_by_ap_id(object.data["id"])
       {:ok, answer_activities, object}
     else
-      {:author, _} -> {:error, "Already voted"}
+      {:author, _} -> {:error, "Poll's author can't vote"}
       {:existing_votes, _} -> {:error, "Already voted"}
       {:choice_check, {_, false}} -> {:error, "Invalid indices"}
       {:count_check, false} -> {:error, "Too many choices"}
@@ -201,8 +201,10 @@ defmodule Pleroma.Web.CommonAPI do
              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),
          context <- make_context(in_reply_to),
          cw <- data["spoiler_text"] || "",
          sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),