Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / lib / pleroma / emoji.ex
index 98644f84e5f195cab27e4175af0c7cc7fac96426..f077fe5b44ec4567cbb9014d8eb788c1c9d5f6b0 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Emoji do
@@ -104,11 +104,19 @@ defmodule Pleroma.Emoji do
 
   @external_resource "lib/pleroma/emoji-test.txt"
 
+  regional_indicators =
+    Enum.map(127_462..127_487, fn codepoint ->
+      <<codepoint::utf8>>
+    end)
+
   emojis =
     @external_resource
     |> File.read!()
     |> String.split("\n")
-    |> Enum.filter(fn line -> line != "" and not String.starts_with?(line, "#") end)
+    |> Enum.filter(fn line ->
+      line != "" and not String.starts_with?(line, "#") and
+        String.contains?(line, "fully-qualified")
+    end)
     |> Enum.map(fn line ->
       line
       |> String.split(";", parts: 2)
@@ -122,6 +130,8 @@ defmodule Pleroma.Emoji do
     end)
     |> Enum.uniq()
 
+  emojis = emojis ++ regional_indicators
+
   for emoji <- emojis do
     def is_unicode_emoji?(unquote(emoji)), do: true
   end