[#483] User.get_by_nickname/1: allowed retrieving user by fully-qualified local nickname

(<nick>@<our_instance_host>).
This commit is contained in:
Ivan Tashkinov 2018-12-29 12:15:46 +03:00
parent 67b4297f4d
commit b3574dccbb

View file

@ -387,7 +387,11 @@ defmodule Pleroma.User do
end
def get_by_nickname(nickname) do
Repo.get_by(User, nickname: nickname)
Repo.get_by(User, nickname: nickname) ||
if String.ends_with?(nickname, "@" <> Pleroma.Web.Endpoint.host()) do
[local_nickname, _] = String.split(nickname, "@")
Repo.get_by(User, nickname: local_nickname)
end
end
def get_by_nickname_or_email(nickname_or_email) do