mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-11-20 08:30:59 +00:00
Merge branch 'bugfix/236-ambiguous-route-for-numerical-handles' into 'develop'
Bugfix #236 Prefer user look-up by nickname See merge request pleroma/pleroma!860
This commit is contained in:
commit
2f00814475
1 changed files with 1 additions and 9 deletions
|
@ -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"}
|
||||
|
||||
|
|
Loading…
Reference in a new issue