delegate user retrieval to the User module
author11backslashes <reversesolidi@protonmail.com>
Sun, 24 Feb 2019 18:23:47 +0000 (13:23 -0500)
committer11backslashes <reversesolidi@protonmail.com>
Sun, 24 Feb 2019 18:23:47 +0000 (13:23 -0500)
lib/pleroma/web/twitter_api/twitter_api.ex

index efdd0bf435ed853fd5d4640d6d4b0da02a340fc2..ab6470d7847443e060787d41970a12aefb6e49d0 100644 (file)
@@ -229,18 +229,10 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
     end
   end
 
-  def get_by_id_or_nickname(id_or_nickname) do
-    if !is_integer(id_or_nickname) && :error == Integer.parse(id_or_nickname) do
-      Repo.get_by(User, nickname: id_or_nickname)
-    else
-      Repo.get(User, id_or_nickname)
-    end
-  end
-
   def get_user(user \\ nil, params) do
     case params do
       %{"user_id" => user_id} ->
-        case target = get_by_id_or_nickname(user_id) do
+        case target = User.get_cached_by_nickname_or_id(user_id) do
           nil ->
             {:error, "No user with such user_id"}