clients.md: Add Kyclos
[akkoma] / lib / pleroma / web / common_api / utils.ex
index 8093a56a683f134005d414869eae53b221199801..a9b164d9ac88a177d0e513aa31f1bb64ee427629 100644 (file)
@@ -231,7 +231,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     no_attachment_links =
       data
       |> Map.get("no_attachment_links", Config.get([:instance, :no_attachment_links]))
-      |> Kernel.in([true, "true"])
+      |> truthy_param?()
 
     content_type = get_content_type(data["content_type"])
 
@@ -431,12 +431,14 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     end
   end
 
-  def emoji_from_profile(%{info: _info} = user) do
-    (Emoji.Formatter.get_emoji(user.bio) ++ Emoji.Formatter.get_emoji(user.name))
-    |> Enum.map(fn {shortcode, %Emoji{file: url}} ->
+  def emoji_from_profile(%User{bio: bio, name: name}) do
+    [bio, name]
+    |> Enum.map(&Emoji.Formatter.get_emoji/1)
+    |> Enum.concat()
+    |> Enum.map(fn {shortcode, %Emoji{file: path}} ->
       %{
         "type" => "Emoji",
-        "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}#{url}"},
+        "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}#{path}"},
         "name" => ":#{shortcode}:"
       }
     end)
@@ -449,6 +451,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     recipients ++ to
   end
 
+  def maybe_notify_to_recipients(recipients, _), do: recipients
+
   def maybe_notify_mentioned_recipients(
         recipients,
         %Activity{data: %{"to" => _to, "type" => type} = data} = activity
@@ -490,7 +494,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     with %User{} = user <- User.get_cached_by_ap_id(actor) do
       subscriber_ids =
         user
-        |> User.subscribers()
+        |> User.subscriber_users()
         |> Enum.filter(&Visibility.visible_for_user?(activity, &1))
         |> Enum.map(& &1.ap_id)
 
@@ -500,6 +504,17 @@ defmodule Pleroma.Web.CommonAPI.Utils do
 
   def maybe_notify_subscribers(recipients, _), do: recipients
 
+  def maybe_notify_followers(recipients, %Activity{data: %{"type" => "Move"}} = activity) do
+    with %User{} = user <- User.get_cached_by_ap_id(activity.actor) do
+      user
+      |> User.get_followers()
+      |> Enum.map(& &1.ap_id)
+      |> Enum.concat(recipients)
+    end
+  end
+
+  def maybe_notify_followers(recipients, _), do: recipients
+
   def maybe_extract_mentions(%{"tag" => tag}) do
     tag
     |> Enum.filter(fn x -> is_map(x) && x["type"] == "Mention" end)