Fix moderation log crash
authorMaxim Filippov <colixer@gmail.com>
Fri, 1 Nov 2019 16:13:29 +0000 (19:13 +0300)
committerMaxim Filippov <colixer@gmail.com>
Fri, 1 Nov 2019 16:13:29 +0000 (19:13 +0300)
lib/pleroma/moderation_log.ex

index e8884e6e81c01bf15a3e0247fb4320831647af1c..9dc4a94c96ab263dab588b34da8abde134c42624 100644 (file)
@@ -369,6 +369,24 @@ defmodule Pleroma.ModerationLog do
     "@#{actor_nickname} created users: #{users_to_nicknames_string(subjects)}"
   end
 
+  @spec get_log_entry_message(ModerationLog) :: String.t()
+  def get_log_entry_message(%ModerationLog{
+        data: %{
+          "actor" => %{"nickname" => actor_nickname},
+          "action" => "activate",
+          "subject" => user
+        }
+      })
+      when is_map(user) do
+    get_log_entry_message(%ModerationLog{
+      data: %{
+        "actor" => %{"nickname" => actor_nickname},
+        "action" => "activate",
+        "subject" => [user]
+      }
+    })
+  end
+
   @spec get_log_entry_message(ModerationLog) :: String.t()
   def get_log_entry_message(%ModerationLog{
         data: %{
@@ -380,6 +398,24 @@ defmodule Pleroma.ModerationLog do
     "@#{actor_nickname} activated users: #{users_to_nicknames_string(users)}"
   end
 
+  @spec get_log_entry_message(ModerationLog) :: String.t()
+  def get_log_entry_message(%ModerationLog{
+        data: %{
+          "actor" => %{"nickname" => actor_nickname},
+          "action" => "deactivate",
+          "subject" => user
+        }
+      })
+      when is_map(user) do
+    get_log_entry_message(%ModerationLog{
+      data: %{
+        "actor" => %{"nickname" => actor_nickname},
+        "action" => "deactivate",
+        "subject" => [user]
+      }
+    })
+  end
+
   @spec get_log_entry_message(ModerationLog) :: String.t()
   def get_log_entry_message(%ModerationLog{
         data: %{
@@ -419,6 +455,26 @@ defmodule Pleroma.ModerationLog do
     "@#{actor_nickname} removed tags: #{tags_string} from users: #{nicknames_to_string(nicknames)}"
   end
 
+  @spec get_log_entry_message(ModerationLog) :: String.t()
+  def get_log_entry_message(%ModerationLog{
+        data: %{
+          "actor" => %{"nickname" => actor_nickname},
+          "action" => "grant",
+          "subject" => user,
+          "permission" => permission
+        }
+      })
+      when is_map(user) do
+    get_log_entry_message(%ModerationLog{
+      data: %{
+        "actor" => %{"nickname" => actor_nickname},
+        "action" => "grant",
+        "subject" => [user],
+        "permission" => permission
+      }
+    })
+  end
+
   @spec get_log_entry_message(ModerationLog) :: String.t()
   def get_log_entry_message(%ModerationLog{
         data: %{
@@ -431,6 +487,26 @@ defmodule Pleroma.ModerationLog do
     "@#{actor_nickname} made #{users_to_nicknames_string(users)} #{permission}"
   end
 
+  @spec get_log_entry_message(ModerationLog) :: String.t()
+  def get_log_entry_message(%ModerationLog{
+        data: %{
+          "actor" => %{"nickname" => actor_nickname},
+          "action" => "revoke",
+          "subject" => user,
+          "permission" => permission
+        }
+      })
+      when is_map(user) do
+    get_log_entry_message(%ModerationLog{
+      data: %{
+        "actor" => %{"nickname" => actor_nickname},
+        "action" => "revoke",
+        "subject" => [user],
+        "permission" => permission
+      }
+    })
+  end
+
   @spec get_log_entry_message(ModerationLog) :: String.t()
   def get_log_entry_message(%ModerationLog{
         data: %{