run mix format
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Fri, 10 Jun 2022 12:41:08 +0000 (13:41 +0100)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Fri, 10 Jun 2022 12:41:08 +0000 (13:41 +0100)
lib/pleroma/emoji.ex
lib/pleroma/web/activity_pub/builder.ex
lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/utils.ex
lib/pleroma/web/mastodon_api/views/status_view.ex
lib/pleroma/web/pleroma_api/views/emoji_reaction_view.ex
mix.exs

index f484f96a0e9ea8f4154af735038b0fe7de270a50..a52df0de3952404a5be3f69cd7a12099d4cb5af8 100644 (file)
@@ -50,13 +50,14 @@ defmodule Pleroma.Emoji do
   @doc "Returns the path of the emoji `name`."
   @spec get(String.t()) :: String.t() | nil
   def get(name) do
-    name = if String.starts_with?(name, ":") do
-      name
-      |> String.replace_leading(":", "")
-      |> String.replace_trailing(":", "")
-    else
-      name
-    end
+    name =
+      if String.starts_with?(name, ":") do
+        name
+        |> String.replace_leading(":", "")
+        |> String.replace_trailing(":", "")
+      else
+        name
+      end
 
     case :ets.lookup(@ets, name) do
       [{_, path}] -> path
index 0ba17a4d5b1f9dd6b36fbd044c21fd3823f42193..652c257210f0a6e3622bb4cfc1f8cac7af166eb1 100644 (file)
@@ -58,29 +58,32 @@ defmodule Pleroma.Web.ActivityPub.Builder do
   @spec emoji_react(User.t(), Object.t(), String.t()) :: {:ok, map(), keyword()}
   def emoji_react(actor, object, emoji) do
     with {:ok, data, meta} <- object_action(actor, object) do
-      data = if Emoji.is_unicode_emoji?(emoji) do
-        data
-        |> Map.put("content", emoji)
-        |> Map.put("type", "EmojiReact")
-      else
-        emojo = Emoji.get(emoji)
-        path = emojo |> Map.get(:file)
-        url = "#{Endpoint.url()}#{path}"
-        data
-        |> Map.put("content", emoji)
-        |> Map.put("type", "EmojiReact")
-        |> Map.put("tag", [
+      data =
+        if Emoji.is_unicode_emoji?(emoji) do
+          data
+          |> Map.put("content", emoji)
+          |> Map.put("type", "EmojiReact")
+        else
+          emojo = Emoji.get(emoji)
+          path = emojo |> Map.get(:file)
+          url = "#{Endpoint.url()}#{path}"
+
+          data
+          |> Map.put("content", emoji)
+          |> Map.put("type", "EmojiReact")
+          |> Map.put("tag", [
             %{}
             |> Map.put("id", url)
             |> Map.put("type", "Emoji")
             |> Map.put("name", emojo.code)
-            |> Map.put("icon",
-                %{}
-                |> Map.put("type", "Image")
-                |> Map.put("url", url)
+            |> Map.put(
+              "icon",
+              %{}
+              |> Map.put("type", "Image")
+              |> Map.put("url", url)
             )
-        ])
-      end
+          ])
+        end
 
       {:ok, data, meta}
     end
index f0eb5417c4991520071a4024bd37419fa4e5b82d..422ab594a8d5ce41cfb500fbc28fe7310849c118 100644 (file)
@@ -55,11 +55,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
       |> CommonFixes.fix_actor()
       |> CommonFixes.fix_activity_addressing()
 
-    data = if Map.has_key?(data, "tag") do
+    data =
+      if Map.has_key?(data, "tag") do
         data
-    else
+      else
         Map.put(data, "tag", [])
-    end
+      end
 
     with %Object{} = object <- Object.normalize(data["object"]) do
       data
@@ -72,6 +73,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
 
   defp validate_emoji(cng) do
     content = get_field(cng, :content)
+
     if Pleroma.Emoji.is_unicode_emoji?(content) || Regex.match?(@emoji_regex, content) do
       cng
     else
index 25aaba1a6a947cb6aa4a9e4cbd39b1fcccc24d46..cf0c9a9e2ffe2e2bc826dc67987f75c968a60a8e 100644 (file)
@@ -433,7 +433,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   def handle_incoming(
         %{
           "type" => "Like",
-          "_misskey_reaction" => reaction,
+          "_misskey_reaction" => reaction
         } = data,
         options
       ) do
index cca58e0daecd7447e94264f1fa7622263e152932..37f7a9173254cb4ed30c6ab25613680e3eea0e90 100644 (file)
@@ -350,14 +350,15 @@ defmodule Pleroma.Web.ActivityPub.Utils do
     reactions = get_cached_emoji_reactions(object)
     emoji = stripped_emoji_name(emoji)
     url = emoji_url(emoji, activity)
+
     new_reactions =
       case Enum.find_index(reactions, fn [candidate, _, candidate_url] ->
-        if is_nil(candidate_url) do
-            emoji == candidate
-        else
-            url == candidate_url
-        end
-      end) do
+             if is_nil(candidate_url) do
+               emoji == candidate
+             else
+               url == candidate_url
+             end
+           end) do
         nil ->
           reactions ++ [[emoji, [actor], url]]
 
@@ -380,12 +381,18 @@ defmodule Pleroma.Web.ActivityPub.Utils do
     |> String.replace_trailing(":", "")
   end
 
-  defp emoji_url(name,
-    %Activity{
-        data: %{"tag" => [
-            %{"type" => "Emoji", "name" => name, "icon" => %{"url" => url}}
-        ]}
-    }), do: url
+  defp emoji_url(
+         name,
+         %Activity{
+           data: %{
+             "tag" => [
+               %{"type" => "Emoji", "name" => name, "icon" => %{"url" => url}}
+             ]
+           }
+         }
+       ),
+       do: url
+
   defp emoji_url(_, _), do: nil
 
   def emoji_count(reactions_list) do
@@ -399,14 +406,15 @@ defmodule Pleroma.Web.ActivityPub.Utils do
     emoji = stripped_emoji_name(emoji)
     reactions = get_cached_emoji_reactions(object)
     url = emoji_url(emoji, activity)
+
     new_reactions =
       case Enum.find_index(reactions, fn [candidate, _, candidate_url] ->
-        if is_nil(candidate_url) do
-            emoji == candidate
-        else
-            url == candidate_url
-        end
-      end) do
+             if is_nil(candidate_url) do
+               emoji == candidate
+             else
+               url == candidate_url
+             end
+           end) do
         nil ->
           reactions
 
@@ -536,11 +544,13 @@ defmodule Pleroma.Web.ActivityPub.Utils do
 
   def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do
     %{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id)
-    emoji = if String.starts_with?(emoji, ":") do
-      emoji
-    else
-      ":#{emoji}:"
-    end
+
+    emoji =
+      if String.starts_with?(emoji, ":") do
+        emoji
+      else
+        ":#{emoji}:"
+      end
 
     "EmojiReact"
     |> Activity.Queries.by_type()
index 90f6f8469a75a918eed4ce426f0b3471f6ee5f5e..008040866adcdf09ad3e7879fe903687a448cc6b 100644 (file)
@@ -304,6 +304,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
         _e ->
           nil
       end
+
     emoji_reactions =
       object.data
       |> Map.get("reactions", [])
index 85eb09d25aed39231f057a6b5ccb7f31e2122c72..9993480dbe224262d92e08f6a28779ca7d73d9a1 100644 (file)
@@ -14,6 +14,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionView do
 
   def render("show.json", %{emoji_reaction: {emoji, user_ap_ids, url}, user: user}) do
     users = fetch_users(user_ap_ids)
+
     %{
       name: emoji,
       count: length(users),
diff --git a/mix.exs b/mix.exs
index 848c51c66d5dc8f38ac6b8e8a76496da3ee248c7..95c9f7f61b3c805387e9d42f92dd46f1b1258920 100644 (file)
--- a/mix.exs
+++ b/mix.exs
@@ -157,7 +157,9 @@ defmodule Pleroma.Mixfile do
       {:floki, "~> 0.27"},
       {:timex, "~> 3.6"},
       {:ueberauth, "~> 0.4"},
-      {:linkify, git: "https://git.ihatebeinga.live/floatingghost/linkify.git", branch: "bugfix/line-ending-buffer"},
+      {:linkify,
+       git: "https://git.ihatebeinga.live/floatingghost/linkify.git",
+       branch: "bugfix/line-ending-buffer"},
       {:http_signatures, "~> 0.1.1"},
       {:telemetry, "~> 0.3"},
       {:poolboy, "~> 1.5"},