diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-09 15:13:37 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-09 15:13:37 +0300 |
commit | ac672a9d6bfdd3cba7692f80a883bd38b0b09a57 (patch) | |
tree | e8a647e2a756d25491957b2ae165a20f816d5049 /lib/pleroma/activity.ex | |
parent | 3965772b261e78669441a5bf3a597f1a69f78a7f (diff) | |
download | pleroma-ac672a9d6bfdd3cba7692f80a883bd38b0b09a57.tar.gz |
[#1559] Addressed code review requests.
Diffstat (limited to 'lib/pleroma/activity.ex')
-rw-r--r-- | lib/pleroma/activity.ex | 8 |
1 files changed, 5 insertions, 3 deletions
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 |