Allow reacting with emojis containing a number
authorsn0w <me@sn0w.cx>
Tue, 14 Jun 2022 09:47:09 +0000 (11:47 +0200)
committersn0w <me@sn0w.cx>
Tue, 14 Jun 2022 09:47:09 +0000 (11:47 +0200)
config/emoji.txt
lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex
priv/static/emoji/100a.png [new file with mode: 0644]
test/pleroma/web/mastodon_api/views/notification_view_test.exs

index 52b714ee5d28e0ad3c90c40e1531d0aff3cdc6d8..1d13437c910378ed13b4ea10d3ffd739609e2971 100644 (file)
@@ -1,3 +1,4 @@
 firefox, /emoji/Firefox.gif, Gif,Fun
 blank, /emoji/blank.png, Fun
 dinosaur, /emoji/dino walking.gif, Gif
+100a, /emoji/100a.png, Fun
index 995395826ed0683b6c1974feea7b7b427e0dac73..f4870f58095033b1eda3499a1925c489f3ca5bd6 100644 (file)
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
   import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
 
   @primary_key false
-  @emoji_regex ~r/:[A-Za-z_-]+:/
+  @emoji_regex ~r/:[A-Za-z0-9_-]+:/
 
   embedded_schema do
     quote do
diff --git a/priv/static/emoji/100a.png b/priv/static/emoji/100a.png
new file mode 100644 (file)
index 0000000..a608bf6
Binary files /dev/null and b/priv/static/emoji/100a.png differ
index 00e90239ec28b6ead33f4340fc10543b14e26fce..31744a59dc2dfededeaa06c3a56e1a3b35daad38 100644 (file)
@@ -202,7 +202,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
     other_user = insert(:user)
 
     {:ok, activity} = CommonAPI.post(user, %{status: "#morb"})
-    {:ok, _activity} = CommonAPI.react_with_emoji(activity.id, other_user, ":dinosaur:")
+    {:ok, _activity} = CommonAPI.react_with_emoji(activity.id, other_user, ":100a:")
 
     activity = Repo.get(Activity, activity.id)
 
@@ -214,8 +214,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
       id: to_string(notification.id),
       pleroma: %{is_seen: false, is_muted: false},
       type: "pleroma:emoji_reaction",
-      emoji: ":dinosaur:",
-      emoji_url: "http://localhost:4001/emoji/dino walking.gif",
+      emoji: ":100a:",
+      emoji_url: "http://localhost:4001/emoji/100a.png",
       account: AccountView.render("show.json", %{user: other_user, for: user}),
       status: StatusView.render("show.json", %{activity: activity, for: user}),
       created_at: Utils.to_masto_date(notification.inserted_at)