Pleroma.Activity.mastodon_notification_type/1

This commit is contained in:
href 2018-12-10 15:50:10 +01:00
commit ec0e613eca
No known key found for this signature in database
GPG key ID: EE8296C1A152C325
3 changed files with 41 additions and 51 deletions

View file

@ -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