From: rinpatch Date: Sun, 13 Jan 2019 10:38:28 +0000 (+0300) Subject: Resolve merge conflict X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=e4dc3f71aea900e566c0d66ddffc5cd57e3920dd;p=akkoma Resolve merge conflict --- e4dc3f71aea900e566c0d66ddffc5cd57e3920dd diff --cc lib/pleroma/user.ex index c86ad4afe,681280539..3120b13b6 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -334,12 -444,12 +453,16 @@@ defmodule Pleroma.User d Cachex.fetch!(:user_cache, key, fn _ -> get_or_fetch_by_nickname(nickname) end) end + def get_cached_by_nickname_or_id(nickname_or_id) do + get_cached_by_nickname(nickname_or_id) || get_cached_by_id(nickname_or_id) + end + def get_by_nickname(nickname) do - Repo.get_by(User, nickname: nickname) + Repo.get_by(User, nickname: nickname) || + if Regex.match?(~r(@#{Pleroma.Web.Endpoint.host()})i, nickname) 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 diff --cc test/web/ostatus/ostatus_controller_test.exs index e9e9bdb16,995cc00d6..8e9d2b69a --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@@ -111,16 -114,31 +115,32 @@@ defmodule Pleroma.Web.OStatus.OStatusCo |> response(404) end + test "gets an activity in xml format", %{conn: conn} do + note_activity = insert(:note_activity) + [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])) + + conn + |> put_req_header("accept", "application/xml") + |> get("/activities/#{uuid}") + |> response(200) + end + + test "404s on deleted objects", %{conn: conn} do + note_activity = insert(:note_activity) + [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])) + object = Object.get_by_ap_id(note_activity.data["object"]["id"]) + + conn + |> get("/objects/#{uuid}") + |> response(200) + + Object.delete(object) + + conn + |> get("/objects/#{uuid}") + |> response(404) + end + - test "gets an activity", %{conn: conn} do - note_activity = insert(:note_activity) - [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])) - - conn - |> get("/activities/#{uuid}") - |> response(200) - end - test "404s on private activities", %{conn: conn} do note_activity = insert(:direct_note_activity) [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"]))