Merge branch 'bug/fix-signatures-for-relay' into 'master'

Bug/fix signatures for relay

See merge request framasoft/mobilizon!360
This commit is contained in:
Thomas Citharel 2019-12-17 13:56:11 +01:00
commit f425565e9e
2 changed files with 11 additions and 1 deletions

View File

@ -20,6 +20,8 @@ defmodule MobilizonWeb.Router do
end end
pipeline :relay do pipeline :relay do
plug(MobilizonWeb.HTTPSignaturePlug)
plug(MobilizonWeb.Plugs.MappedSignatureToIdentity)
plug(:accepts, ["activity-json", "json"]) plug(:accepts, ["activity-json", "json"])
end end

View File

@ -118,7 +118,15 @@ defmodule Mobilizon.Service.ActivityPub do
Getting an actor from url, eventually creating it Getting an actor from url, eventually creating it
""" """
@spec get_or_fetch_actor_by_url(String.t(), boolean) :: {:ok, Actor.t()} | {:error, String.t()} @spec get_or_fetch_actor_by_url(String.t(), boolean) :: {:ok, Actor.t()} | {:error, String.t()}
def get_or_fetch_actor_by_url(url, preload \\ false) do def get_or_fetch_actor_by_url(url, preload \\ false)
def get_or_fetch_actor_by_url("https://www.w3.org/ns/activitystreams#Public", _preload) do
with %Actor{url: url} <- Relay.get_actor() do
get_or_fetch_actor_by_url(url)
end
end
def get_or_fetch_actor_by_url(url, preload) do
case Actors.get_actor_by_url(url, preload) do case Actors.get_actor_by_url(url, preload) do
{:ok, %Actor{} = actor} -> {:ok, %Actor{} = actor} ->
{:ok, actor} {:ok, actor}