Fix unused variables, imports, and aliases
[akkoma] / lib / pleroma / web / twitter_api / views / user_view.ex
index cc6b450fb1f6067ced932388acb1774ccde0934a..31527caae4aec202fc490fd0ad8236e491843555 100644 (file)
@@ -14,20 +14,22 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
 
   def render("user.json", %{user: user = %User{}} = assigns) do
     image = User.avatar_url(user) |> MediaProxy.url()
-    {following, follows_you, statusnet_blocking} = if assigns[:for] do
-      {
-        User.following?(assigns[:for], user),
-        User.following?(user, assigns[:for]),
-        User.blocks?(assigns[:for], user)
-      }
-    else
-      {false, false, false}
-    end
+
+    {following, follows_you, statusnet_blocking} =
+      if assigns[:for] do
+        {
+          User.following?(assigns[:for], user),
+          User.following?(user, assigns[:for]),
+          User.blocks?(assigns[:for], user)
+        }
+      else
+        {false, false, false}
+      end
 
     user_info = User.get_cached_user_info(user)
 
     data = %{
-      "created_at" => user.inserted_at |> Utils.format_naive_asctime,
+      "created_at" => user.inserted_at |> Utils.format_naive_asctime(),
       "description" => HtmlSanitizeEx.strip_tags(user.bio),
       "favourites_count" => 0,
       "followers_count" => user_info[:follower_count],
@@ -41,12 +43,15 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
       "profile_image_url_https" => image,
       "profile_image_url_profile_size" => image,
       "profile_image_url_original" => image,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => !!user.info["is_moderator"]
+      },
       "screen_name" => user.nickname,
       "statuses_count" => user_info[:note_count],
       "statusnet_profile_url" => user.ap_id,
-      "cover_photo" => image_url(user.info["banner"]) |> MediaProxy.url(),
+      "cover_photo" => User.banner_url(user) |> MediaProxy.url(),
       "background_image" => image_url(user.info["background"]) |> MediaProxy.url(),
+      "is_local" => user.local
     }
 
     if assigns[:token] do
@@ -56,9 +61,14 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
     end
   end
 
-  def render("short.json", %{user: %User{
-                               nickname: nickname, id: id, ap_id: ap_id, name: name
-                           }}) do
+  def render("short.json", %{
+        user: %User{
+          nickname: nickname,
+          id: id,
+          ap_id: ap_id,
+          name: name
+        }
+      }) do
     %{
       "fullname" => name,
       "id" => id,
@@ -68,6 +78,6 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
     }
   end
 
-  defp image_url(%{"url" => [ %{ "href" => href } | _ ]}), do: href
+  defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
   defp image_url(_), do: nil
 end