forked from AkkomaGang/akkoma
Handle incoming emoji.
This commit is contained in:
parent
884006a9e9
commit
16b1fcd271
3 changed files with 15 additions and 0 deletions
|
@ -52,6 +52,17 @@ def get_mentions(entry) do
|
||||||
|> Enum.filter(&(&1))
|
|> Enum.filter(&(&1))
|
||||||
end
|
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
|
def make_to_list(actor, mentions) do
|
||||||
[
|
[
|
||||||
actor.follower_address
|
actor.follower_address
|
||||||
|
@ -95,6 +106,7 @@ def handle_note(entry, doc \\ nil) do
|
||||||
note <- CommonAPI.Utils.make_note_data(actor.ap_id, to, context, content_html, attachments, inReplyToActivity, []),
|
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("id", id) |> Map.put("tag", tags),
|
||||||
note <- note |> Map.put("published", date),
|
note <- note |> Map.put("published", date),
|
||||||
|
note <- note |> Map.put("emoji", get_emoji(entry)),
|
||||||
note <- add_external_url(note, entry),
|
note <- add_external_url(note, entry),
|
||||||
# TODO: Handle this case in make_note_data
|
# TODO: Handle this case in make_note_data
|
||||||
note <- (if inReplyTo && !inReplyToActivity, do: note |> Map.put("inReplyTo", inReplyTo), else: note)
|
note <- (if inReplyTo && !inReplyToActivity, do: note |> Map.put("inReplyTo", inReplyTo), else: note)
|
||||||
|
|
2
test/fixtures/incoming_note_activity.xml
vendored
2
test/fixtures/incoming_note_activity.xml
vendored
|
@ -4,6 +4,8 @@
|
||||||
<title>New note by lambda</title>
|
<title>New note by lambda</title>
|
||||||
<content type="html">@<a href="http://pleroma.example.org:4000/users/lain3" class="h-card mention">lain3</a></content>
|
<content type="html">@<a href="http://pleroma.example.org:4000/users/lain3" class="h-card mention">lain3</a></content>
|
||||||
<link rel="alternate" type="text/html" href="http://gs.example.org:4040/index.php/notice/29"/>
|
<link rel="alternate" type="text/html" href="http://gs.example.org:4040/index.php/notice/29"/>
|
||||||
|
<link name="marko" rel="emoji" href="marko.png" />
|
||||||
|
<link name="reimu" rel="emoji" href="reimu.png" />
|
||||||
<status_net notice_id="29"></status_net>
|
<status_net notice_id="29"></status_net>
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
<published>2017-04-23T14:51:03+00:00</published>
|
<published>2017-04-23T14:51:03+00:00</published>
|
||||||
|
|
|
@ -24,6 +24,7 @@ test "handle incoming note - GS, Salmon" do
|
||||||
assert activity.data["object"]["published"] == "2017-04-23T14:51:03+00:00"
|
assert activity.data["object"]["published"] == "2017-04-23T14:51:03+00:00"
|
||||||
assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
|
assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
|
||||||
assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
|
assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
|
||||||
|
assert activity.data["object"]["emoji"] == %{ "marko" => "marko.png", "reimu" => "reimu.png" }
|
||||||
assert activity.local == false
|
assert activity.local == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue