def fetch_and_contain_remote_object_from_id(id) when is_binary(id) do
Logger.info("Fetching object #{id} via AP")
- date =
- NaiveDateTime.utc_now()
- |> Timex.format!("{WDshort}, {0D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
+ date = Pleroma.Signature.signed_date()
headers =
[{:Accept, "application/activity+json"}]
HTTPSignatures.sign(private_key, user.ap_id <> "#main-key", headers)
end
end
+
+ def signed_date, do: signed_date(NaiveDateTime.utc_now())
+
+ def signed_date(%NaiveDateTime{} = date) do
+ Timex.format!(date, "{WDshort}, {0D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
+ end
end
digest = "SHA-256=" <> (:crypto.hash(:sha256, json) |> Base.encode64())
- date =
- NaiveDateTime.utc_now()
- |> Timex.format!("{WDshort}, {0D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
+ date = Pleroma.Signature.signed_date()
signature =
Pleroma.Signature.sign(actor, %{
})
end
+ pipeline :http_signature do
+ plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
+ end
+
scope "/api/pleroma", Pleroma.Web.TwitterAPI do
pipe_through(:pleroma_api)
pipe_through(:ap_service_actor)
get("/", ActivityPubController, :relay)
- post("/inbox", ActivityPubController, :inbox)
+
+ scope [] do
+ pipe_through(:http_signature)
+ post("/inbox", ActivityPubController, :inbox)
+ end
get("/following", ActivityPubController, :following, assigns: %{relay: true})
get("/followers", ActivityPubController, :followers, assigns: %{relay: true})