Formatting.
authorlain <lain@soykaf.club>
Fri, 20 Apr 2018 11:10:57 +0000 (13:10 +0200)
committerlain <lain@soykaf.club>
Fri, 20 Apr 2018 11:10:57 +0000 (13:10 +0200)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/twitter_api/views/notification_view.ex
test/web/twitter_api/twitter_api_controller_test.exs
test/web/twitter_api/views/notification_view_test.exs

index 10531ec15126b46c40959dd4e3d023b841e9b645..8b3492332c23340a6ee5a25c4c6e1fdcf9436931 100644 (file)
@@ -217,8 +217,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         activities = []
       else
         activities =
-         ActivityPub.fetch_public_activities(params)
-         |> Enum.reverse()
+          ActivityPub.fetch_public_activities(params)
+          |> Enum.reverse()
       end
 
       conn
index 4e1ba0b544604fd8bfa6a06486ebdf849bf8db02..f41edea0b3b55e58b5ad9d213128a3850f22ad52 100644 (file)
@@ -23,16 +23,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 +58,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
index 18a3243f5ff0584caca42caf42b8f02334e4f174..406dace1cdb74832ed70cf0834618fe9a63ca5e6 100644 (file)
@@ -270,10 +270,10 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
       assert length(response) == 1
 
       assert response ==
-        NotificationView.render(
-          "notification.json",
-          %{notifications: Notification.for_user(current_user), for: current_user}
-        )
+               NotificationView.render("notification.json", %{
+                 notifications: Notification.for_user(current_user),
+                 for: current_user
+               })
     end
   end
 
index 33aaa89e114e741cd8f5d05277f1b1508f961b30..e3b1406573ccbb7a21ac5511f28d2fb65a632e18 100644 (file)
@@ -36,14 +36,17 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
       "ntype" => "follow"
     }
 
-    assert represented == NotificationView.render("notification.json", %{notification: follow_notif, for: user})
+    assert represented ==
+             NotificationView.render("notification.json", %{notification: follow_notif, for: user})
   end
 
   test "A mention notification" do
     user = insert(:user)
     other_user = insert(:user)
 
-    {:ok, activity} = TwitterAPI.create_status(other_user, %{"status" => "Päivää, @#{user.nickname}"})
+    {:ok, activity} =
+      TwitterAPI.create_status(other_user, %{"status" => "Päivää, @#{user.nickname}"})
+
     [notification] = Notification.for_user(user)
 
     represented = %{
@@ -55,7 +58,8 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
       "ntype" => "mention"
     }
 
-    assert represented == NotificationView.render("notification.json", %{notification: notification, for: user})
+    assert represented ==
+             NotificationView.render("notification.json", %{notification: notification, for: user})
   end
 
   test "A retweet notification" do
@@ -71,11 +75,13 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
       "from_profile" => UserView.render("show.json", %{user: repeater, for: user}),
       "id" => notification.id,
       "is_seen" => 0,
-      "notice" => ActivityView.render("activity.json", %{activity: notification.activity, for: user}),
+      "notice" =>
+        ActivityView.render("activity.json", %{activity: notification.activity, for: user}),
       "ntype" => "repeat"
     }
 
-    assert represented == NotificationView.render("notification.json", %{notification: notification, for: user})
+    assert represented ==
+             NotificationView.render("notification.json", %{notification: notification, for: user})
   end
 
   test "A like notification" do
@@ -91,10 +97,12 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
       "from_profile" => UserView.render("show.json", %{user: liker, for: user}),
       "id" => notification.id,
       "is_seen" => 0,
-      "notice" => ActivityView.render("activity.json", %{activity: notification.activity, for: user}),
+      "notice" =>
+        ActivityView.render("activity.json", %{activity: notification.activity, for: user}),
       "ntype" => "like"
     }
 
-    assert represented == NotificationView.render("notification.json", %{notification: notification, for: user})
+    assert represented ==
+             NotificationView.render("notification.json", %{notification: notification, for: user})
   end
 end