@@ -83,13 +83,13 @@ defmodule EventosWeb.ActivityPubController do
|
||||
def inbox(conn, params) do
|
||||
headers = Enum.into(conn.req_headers, %{})
|
||||
|
||||
if !String.contains?(headers["signature"] || "", params["actor"]) do
|
||||
Logger.info("Signature not from author, relayed message, fetching from source")
|
||||
ActivityPub.fetch_event_from_url(params["object"]["id"])
|
||||
else
|
||||
if String.contains?(headers["signature"] || "", params["actor"]) do
|
||||
Logger.info("Signature error")
|
||||
Logger.info("Could not validate #{params["actor"]}")
|
||||
Logger.info(inspect(conn.req_headers))
|
||||
else
|
||||
Logger.info("Signature not from author, relayed message, fetching from source")
|
||||
ActivityPub.fetch_event_from_url(params["object"]["id"])
|
||||
end
|
||||
|
||||
json(conn, "ok")
|
||||
|
||||
@@ -60,7 +60,7 @@ defmodule EventosWeb.EventController do
|
||||
end
|
||||
|
||||
def export_to_ics(conn, %{"uuid" => uuid}) do
|
||||
event = Events.get_event_full_by_uuid(uuid) |> ICalendar.export_event()
|
||||
event = uuid |> Events.get_event_full_by_uuid() |> ICalendar.export_event()
|
||||
send_resp(conn, 200, event)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
defmodule EventosWeb.HTTPSignaturePlug do
|
||||
@moduledoc """
|
||||
# HTTPSignaturePlug
|
||||
|
||||
Plug to check HTTP Signatures on every incoming request
|
||||
"""
|
||||
|
||||
alias Eventos.Service.HTTPSignatures
|
||||
import Plug.Conn
|
||||
require Logger
|
||||
@@ -13,7 +19,9 @@ defmodule EventosWeb.HTTPSignaturePlug do
|
||||
|
||||
def call(conn, _opts) do
|
||||
user = conn.params["actor"]
|
||||
Logger.debug("Checking sig for #{user}")
|
||||
Logger.debug fn ->
|
||||
"Checking sig for #{user}"
|
||||
end
|
||||
with [signature | _] <- get_req_header(conn, "signature") do
|
||||
cond do
|
||||
signature && String.contains?(signature, user) ->
|
||||
|
||||
@@ -49,9 +49,9 @@ defmodule EventosWeb.ActivityPub.ActorView do
|
||||
end
|
||||
|
||||
def render("following.json", %{actor: actor, page: page}) do
|
||||
following = Actor.get_followings(actor)
|
||||
|
||||
collection(following, actor.following_url, page)
|
||||
actor
|
||||
|> Actor.get_followings()
|
||||
|> collection(actor.following_url, page)
|
||||
|> Map.merge(Utils.make_json_ld_header())
|
||||
end
|
||||
|
||||
@@ -68,9 +68,9 @@ defmodule EventosWeb.ActivityPub.ActorView do
|
||||
end
|
||||
|
||||
def render("followers.json", %{actor: actor, page: page}) do
|
||||
followers = Actor.get_followers(actor)
|
||||
|
||||
collection(followers, actor.followers_url, page)
|
||||
actor
|
||||
|> Actor.get_followers()
|
||||
|> collection(actor.followers_url, page)
|
||||
|> Map.merge(Utils.make_json_ld_header())
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user