2024-02-28 18:20:20
2023-08-29 15:12:57
2023-08-29 10:25:11
1778955
doing a little federation
cc @alex how to decide whether to fetch https://mostr.pub/objects/<eventid> since most are {“error”:”Not found”} so i don’t mess up your caches
#AGP compliance as always
defmodule Pleroma.Mostr.Relay do
use WebSockex
require Logger
def start_link(state) do
{:ok, pid} = WebSockex.start_link("wss://relay.mostr.pub", __MODULE__, state)
WebSockex.send_frame(pid, {:text, ~s(["REQ", "relay", {"limit": 0, "kinds": [1,7]}])})
{:ok, pid}
end
def handle_frame({type, msg}, state) do
try do
with :text <- type,
{:ok, ["EVENT", "relay", %{"tags" => tags}]} <- Jason.decode(msg) do
Enum.map(tags, fn tag ->
with ["proxy", uri, "activitypub"] <- tag do
with {:ok, obj} <-
Pleroma.Object.Fetcher.fetch_and_contain_remote_object_from_id(uri),
%{"type" => type, "id" => id} <- obj do
case type do
"Note" ->
Pleroma.Object.Fetcher.fetch_object_from_id(id)
"Like" ->
with %{"object" => %{"data" => %{"id" => id}}} <- obj do
Pleroma.Object.Fetcher.fetch_object_from_id(id)
Pleroma.Web.Federator.perform(:incoming_ap_doc, %{obj | "object" => id})
end
"EmojiReact" ->
with %{"object" => %{"data" => %{"id" => id}}} <- obj do
Pleroma.Object.Fetcher.fetch_object_from_id(id)
Pleroma.Web.Federator.perform(:incoming_ap_doc, %{obj | "object" => id})
end
end
end
end
end)
end
rescue
e -> Logger.error("MOSTR #{e}")
end
{:ok, state}
end
end
This entry was edited (1 year ago)
Alex Gleason
•:gcp: is happening
•:gcp: is happening
•Alex Gleason
•:gcp: is happening
•Feb 28 19:51:26 eldorado elixir[3096182]: 19:51:26.737 [error] Object rejected while fetching https://mostr.pub/objects/83922c28981aa95f89627ccd6ac86bea8785f2b0fae7fc562b9271d457a1ca1f {:fetch, {:error, :timeout}}
Feb 28 19:54:04 eldorado elixir[3096182]: 19:54:04.799 [error] Object rejected while fetching https://mostr.pub/objects/035ec00bc91317d091bf9fd58f7bba838a15b2fa8cd0b813917ba6c795455429 {:fetch, {:error, :timeout}}
Feb 28 1... show more
Feb 28 19:51:26 eldorado elixir[3096182]: 19:51:26.737 [error] Object rejected while fetching https://mostr.pub/objects/83922c28981aa95f89627ccd6ac86bea8785f2b0fae7fc562b9271d457a1ca1f {:fetch, {:error, :timeout}}
Feb 28 19:54:04 eldorado elixir[3096182]: 19:54:04.799 [error] Object rejected while fetching https://mostr.pub/objects/035ec00bc91317d091bf9fd58f7bba838a15b2fa8cd0b813917ba6c795455429 {:fetch, {:error, :timeout}}
Feb 28 19:54:52 eldorado elixir[3096182]: 19:54:52.957 [error] Object rejected while fetching https://mostr.pub/objects/b2e42cd961ca1b8025a22b41f8b4abb3865efb33763d9cd255f039d60f88cb74 {:fetch, {:error, :timeout}}
Feb 28 19:54:53 eldorado elixir[3096182]: 19:54:53.181 [error] Object rejected while fetching https://mostr.pub/objects/a27687e6fceda3cf2c6dce25b3214c7fe0300b66f9458cf0d89d5cbda8405226 {:fetch, {:error, :timeout}}
Feb 28 19:56:18 eldorado elixir[3096182]: 19:56:18.473 [error] Object rejected while fetching https://mostr.pub/objects/a8e5ebc2be5dc6acead423be0bb2db6241fd1a294e5e00ffb604772d0cec3c40 {:fetch, {:error, :timeout}}
Feb 28 19:56:26 eldorado elixir[3096182]: 19:56:26.960 [error] Object rejected while fetching https://mostr.pub/objects/7c299024ca431e36febbb5223d18d13c957355214365709f7cd881b988282712 {:fetch, {:error, :timeout}}
Feb 28 19:56:27 eldorado elixir[3096182]: 19:56:27.358 [error] Object rejected while fetching https://mostr.pub/objects/648cbb19d41c8e91ec1a09fc7f6dfa1703ac1f8185cf92497444f252fe8a9fe7 {:fetch, {:error, :timeout}}
Feb 28 19:56:33 eldorado elixir[3096182]: 19:56:33.609 [error] Object rejected while fetching https://mostr.pub/objects/093b5e810e428c2495868794927af3bfa2ab2eff5b83ec5aaae1870dd7f3c463 {:fetch, {:error, :timeout}}
Feb 28 19:57:02 eldorado elixir[3096182]: 19:57:02.455 [error] Object rejected while fetching https://mostr.pub/objects/9e8e86a8f4abf87660612ce13d38eaeca54d701b291608e6226c71f39766385c {:fetch, {:error, :timeout}}
Feb 28 19:57:56 eldorado elixir[3096182]: 19:57:56.579 [error] Object rejected while fetching https://mostr.pub/objects/456436233cd3e8097146099f4c6430ed0331d0bcb2dfb929f983a271ad969f18 {:fetch, {:error, :timeout}}
Feb 28 19:57:56 eldorado elixir[3096182]: 19:57:56.587 [error] Object rejected while fetching https://mostr.pub/objects/f602e2b7798e2d31176b63804dc05f84def8b2f943e513aca33971c62e647495 {:fetch, {:error, :timeout}}
Feb 28 19:58:21 eldorado elixir[3096182]: 19:58:21.563 [error] Object rejected while fetching https://mostr.pub/objects/8cd6337c143e7d6025995505290121368f1a6eb1afd43f04b4f06b9e1c1b129f {:fetch, {:error, :timeout}}
Feb 28 19:58:25 eldorado elixir[3096182]: 19:58:25.660 [error] Object rejected while fetching https://mostr.pub/objects/fcf10d17a080006c09a7f07f69b38b9d0eb25711a92d99e5e708c69f285f45e8 {:fetch, {:error, :timeout}}
Feb 28 19:58:25 eldorado elixir[3096182]: 19:58:25.666 [error] Object rejected while fetching https://mostr.pub/objects/fcf10d17a080006c09a7f07f69b38b9d0eb25711a92d99e5e708c69f285f45e8 {:fetch, {:error, :timeout}}
Short Text Note by QW
QW (npub1tvq…krq4)Alex Gleason
•@iAll of those give me AP objects when I fetch them over curl with -H 'accept: application/activity+json'
What is your timeout set to? Bridge is not always fast (can take a few seconds the first time an event is requested), but it usually does return a response.
:gcp: is happening
•timeout should already be 15s, i'll double it and see if that doesn't help long term
thanks for keeping the bridge running, i'd host my own, but the goal is harvest messages to fill out the twkn
i should probably just implement the whole relay conversion myself at some point
Alex Gleason
•