add support for all status type (ostatus) and replase case with if
authorSachin Joshi <satchin.joshi@gmail.com>
Tue, 2 Apr 2019 06:30:41 +0000 (12:15 +0545)
committerSachin Joshi <satchin.joshi@gmail.com>
Tue, 2 Apr 2019 06:33:00 +0000 (12:18 +0545)
lib/pleroma/web/twitter_api/controllers/util_controller.ex

index 2a1c731116ccec983e810336da27928254bbb581..b661c4363a668392ea57e3cad6c923fb08b52cd7 100644 (file)
@@ -74,38 +74,39 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
   end
 
   def remote_follow(%{assigns: %{user: user}} = conn, %{"acct" => acct}) do
-    case is_status?(acct) do
-      true ->
-        {:ok, object} = ActivityPub.fetch_object_from_id(acct)
-        %Activity{id: activity_id} = Activity.get_create_by_object_ap_id(object.data["id"])
-        redirect(conn, to: "/notice/#{activity_id}")
-
-      false ->
-        {err, followee} = OStatus.find_or_make_user(acct)
-        avatar = User.avatar_url(followee)
-        name = followee.nickname
-        id = followee.id
-
-        if !!user do
-          conn
-          |> render("follow.html", %{error: err, acct: acct, avatar: avatar, name: name, id: id})
-        else
-          conn
-          |> render("follow_login.html", %{
-            error: false,
-            acct: acct,
-            avatar: avatar,
-            name: name,
-            id: id
-          })
-        end
+    if is_status?(acct) do
+      {:ok, object} = ActivityPub.fetch_object_from_id(acct)
+      %Activity{id: activity_id} = Activity.get_create_by_object_ap_id(object.data["id"])
+      redirect(conn, to: "/notice/#{activity_id}")
+    else
+      {err, followee} = OStatus.find_or_make_user(acct)
+      avatar = User.avatar_url(followee)
+      name = followee.nickname
+      id = followee.id
+
+      if !!user do
+        conn
+        |> render("follow.html", %{error: err, acct: acct, avatar: avatar, name: name, id: id})
+      else
+        conn
+        |> render("follow_login.html", %{
+          error: false,
+          acct: acct,
+          avatar: avatar,
+          name: name,
+          id: id
+        })
+      end
     end
   end
 
   defp is_status?(acct) do
     case ActivityPub.fetch_and_contain_remote_object_from_id(acct) do
-      {:ok, %{"type" => "Note"}} -> true
-      _ -> false
+      {:ok, %{"type" => type}} when type in ["Article", "Note", "Video", "Page", "Question"] ->
+        true
+
+      _ ->
+        false
     end
   end