diff options
author | href <href@random.sh> | 2018-12-10 15:50:10 +0100 |
---|---|---|
committer | href <href@random.sh> | 2018-12-14 13:22:10 +0100 |
commit | ec0e613ecaa8dc411e0c821c4c9b2ca893b45f67 (patch) | |
tree | bfbae29703332381cd24653e52e985906e9ff514 /lib/pleroma/activity.ex | |
parent | 331396cbcdabe9dbfe0b84ec299a642385093605 (diff) | |
download | pleroma-ec0e613ecaa8dc411e0c821c4c9b2ca893b45f67.tar.gz |
Pleroma.Activity.mastodon_notification_type/1
Diffstat (limited to 'lib/pleroma/activity.ex')
-rw-r--r-- | lib/pleroma/activity.ex | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index c065f3b6c..200addd6e 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -3,6 +3,14 @@ defmodule Pleroma.Activity do alias Pleroma.{Repo, Activity, Notification} import Ecto.Query + # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19 + @mastodon_notification_types %{ + "Create" => "mention", + "Follow" => "follow", + "Announce" => "reblog", + "Like" => "favourite" + } + schema "activities" do field(:data, :map) field(:local, :boolean, default: true) @@ -88,4 +96,11 @@ defmodule Pleroma.Activity do end def get_in_reply_to_activity(_), do: nil + + for {ap_type, type} <- @mastodon_notification_types do + def mastodon_notification_type(%Activity{data: %{"type" => unquote(ap_type)}}), + do: unquote(type) + end + + def mastodon_notification_type(%Activity{}), do: nil end |