aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-09-16 16:27:48 +0200
committerRoger Braun <roger@rogerbraun.net>2017-09-16 16:27:48 +0200
commit16b1fcd2719b744c81851e778df2519dc0131010 (patch)
treee17db4b09a20cd5f746dea3a8d4f2187cb9b8f4c /lib
parent884006a9e973dff527ec51e08b3d6a99edfdd93d (diff)
downloadpleroma-16b1fcd2719b744c81851e778df2519dc0131010.tar.gz
Handle incoming emoji.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/ostatus/handlers/note_handler.ex12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/pleroma/web/ostatus/handlers/note_handler.ex b/lib/pleroma/web/ostatus/handlers/note_handler.ex
index 0b06f8f02..dda5c7d5e 100644
--- a/lib/pleroma/web/ostatus/handlers/note_handler.ex
+++ b/lib/pleroma/web/ostatus/handlers/note_handler.ex
@@ -52,6 +52,17 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
|> Enum.filter(&(&1))
end
+ def get_emoji(entry) do
+ try do
+ :xmerl_xpath.string('//link[@rel="emoji"]', entry)
+ |> Enum.reduce(%{}, fn(emoji, acc) ->
+ Map.put(acc, XML.string_from_xpath("@name", emoji), XML.string_from_xpath("@href", emoji))
+ end)
+ rescue
+ _e -> nil
+ end
+ end
+
def make_to_list(actor, mentions) do
[
actor.follower_address
@@ -95,6 +106,7 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
note <- CommonAPI.Utils.make_note_data(actor.ap_id, to, context, content_html, attachments, inReplyToActivity, []),
note <- note |> Map.put("id", id) |> Map.put("tag", tags),
note <- note |> Map.put("published", date),
+ note <- note |> Map.put("emoji", get_emoji(entry)),
note <- add_external_url(note, entry),
# TODO: Handle this case in make_note_data
note <- (if inReplyTo && !inReplyToActivity, do: note |> Map.put("inReplyTo", inReplyTo), else: note)