X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Factivity.ex;h=6213d0eb7cb732142325b11ec235140ca6677c4f;hb=8bdf18d7c10f0e740b2f5e0fa5063c522b8b3872;hp=3803d8e501df5210c10b0db2c6d2d1d76bae564c;hpb=1a4875adfa8fa8f65f1db7b4ec3cf868b7e3dee7;p=akkoma diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 3803d8e50..6213d0eb7 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -300,6 +300,8 @@ defmodule Pleroma.Activity do def follow_accepted?(_), do: false + @spec mastodon_notification_type(Activity.t()) :: String.t() | nil + for {ap_type, type} <- @mastodon_notification_types, not is_list(type) do def mastodon_notification_type(%Activity{data: %{"type" => unquote(ap_type)}}), do: unquote(type) @@ -315,11 +317,11 @@ defmodule Pleroma.Activity do def mastodon_notification_type(%Activity{}), do: nil + @spec from_mastodon_notification_type(String.t()) :: String.t() | nil + @doc "Converts Mastodon notification type to AR activity type" def from_mastodon_notification_type(type) do with {k, _v} <- - Enum.find(@mastodon_notification_types, fn {_k, v} -> - v == type or (is_list(v) and type in v) - end) do + Enum.find(@mastodon_notification_types, fn {_k, v} -> type in List.wrap(v) end) do k end end