Merge branch 'captcha' into 'develop'
[akkoma] / lib / pleroma / web / twitter_api / views / notification_view.ex
index 4e1ba0b544604fd8bfa6a06486ebdf849bf8db02..d6a1c0a4d78e07a94446fed04744d6b8407944bb 100644 (file)
@@ -1,8 +1,11 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.TwitterAPI.NotificationView do
   use Pleroma.Web, :view
   alias Pleroma.{Notification, User}
   alias Pleroma.Web.CommonAPI.Utils
-  alias Pleroma.Web.MediaProxy
   alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Web.TwitterAPI.ActivityView
 
@@ -23,16 +26,34 @@ defmodule Pleroma.Web.TwitterAPI.NotificationView do
   end
 
   def render("notification.json", %{notifications: notifications, for: user}) do
-    render_many(notifications, Pleroma.Web.TwitterAPI.NotificationView, "notification.json", for: user)
+    render_many(
+      notifications,
+      Pleroma.Web.TwitterAPI.NotificationView,
+      "notification.json",
+      for: user
+    )
   end
 
-  def render("notification.json", %{notification: %Notification{id: id, seen: seen, activity: activity, inserted_at: created_at}, for: user} = opts) do
-    ntype = case activity.data["type"] do
-              "Create" -> "mention"
-              "Like" -> "like"
-              "Announce" -> "repeat"
-              "Follow" -> "follow"
-            end
+  def render(
+        "notification.json",
+        %{
+          notification: %Notification{
+            id: id,
+            seen: seen,
+            activity: activity,
+            inserted_at: created_at
+          },
+          for: user
+        } = opts
+      ) do
+    ntype =
+      case activity.data["type"] do
+        "Create" -> "mention"
+        "Like" -> "like"
+        "Announce" -> "repeat"
+        "Follow" -> "follow"
+      end
+
     from = get_user(activity.data["actor"], opts)
 
     %{
@@ -40,7 +61,7 @@ defmodule Pleroma.Web.TwitterAPI.NotificationView do
       "ntype" => ntype,
       "notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
       "from_profile" => UserView.render("show.json", %{user: from, for: user}),
-      "is_seen" => (if seen, do: 1, else: 0),
+      "is_seen" => if(seen, do: 1, else: 0),
       "created_at" => created_at |> Utils.format_naive_asctime()
     }
   end