Closed maybeanerd closed 6 months ago
maybe using this lib is an option: https://jsr.io/@fedify/fedify https://fedify.dev/manual/
looks like that didnt work out, it's only for deno
other intersting projects: https://github.com/immers-space/activitypub-express https://github.com/michaelcpuckett/activity-kit
Guides
https://socialhub.activitypub.rocks/t/guide-for-new-activitypub-implementers/479
found in the top link, but for quicker access: https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
https://github.com/digitalbazaar/jsonld.js to use json-LD compaction and stuff
For testing, will finally be released later today https://pubkit.net/
Idea: mark all AP related things as handled/unhandled Once applied( aka the change is reflected in the games Data tables) they are marked as handled and essentially ignored from then on This can also be used to handle worker queues that Go through unhandled activities chronologically
This would mean self-created activities are Always handled when created
Better idea for marking handled: Create an ActivityQueue table All AP activities that are created have an entry there with their ID as FK, and a Type Incoming|Outgoing This way workers can pick up this Queue and either Post activities to other servers, or sync them to the Server state
For now as a POC These workers could Run as cronjobs on the main thread. Later on they could become fully Independent workers. Theoretically even Independent containers
Example of how to use extensions:
https://github.com/w3c/activitypub/issues/313#issuecomment-396652190
Some context for the outbox:
IMO it should return all activities of the instance actor, supporting pagination of course (and maybe a startFrom Date attribute)
The main goal should be for other instances to backfill actions , e.g. if they were down for a while, or just recently started a treaty.
Ideas for Inbox: Never use actor from Incoming activity ( only it's ID) If it's a new actor, get it and it's Key to validate the request If it's known, validate with the stored key
bug to look into when federating trades:
Seems like this is the issue: https://github.com/maybeanerd/selfhosted-api-trader-game/blob/main/backend%2Fsrc%2Fmodules%2Ftrade%2Ftrade.service.ts#L110
Maybe move the APobject creation to a util just like the Activity creation? To enforce actorIDs being correct
moved some follow up tasks to https://github.com/maybeanerd/selfhosted-api-trader-game/issues/635
I don't want to use a custom REST based event stream. I don't want to use graphQL here.
Let's use ActivityPub We can start easy A Server is a single actor Following is the "treaty" You can Post trades, and like to "confirm" them.
Let's make it actually be "compatible" with Mastodon. I't wont be any fun to follow a Game Server But it would be possible.
Might be nice to not embed game info in posts, but rather add AP extensions for the game. (Here's sime examples from mastodon: https://docs.joinmastodon.org/spec/activitypub/#toot)
This might allow for a post to describe the Action, e.g. "Basti wants to trade 5 wood for 5 steel in GameNameHere", and add the Game and Action meta to it in extensions. This would allow others to make sense of the posts, If they were to follow.
For Likes, one could probably add an extensions for the game as well, where it specifies the trade response and which player accepted, etc?
The single actor of the instance could be merchant@trading-game.yourDomain.com
An interesting thing to solve is: who to federate with Up until now I wanted a single server to only directly connect to a few others, and then allow trade proxied by them.
Maybe this is still possible by them creating Proxy-Posts? I also thought of discovering follower instances and directly following them, but w core Game mechanic will be travel duration or taxing for Proxy even, so I don't think that's a nice solution. Of course a game server can mark other instances they follow as "No direct Connection", but i Kind of Like the idea of there actually Not being a direct connection
To allow the wider integration into the fediverse, one could limit following only for Game instances, and allow any amount of other AP services to follow and interact without Limit. Internally the Game Server will ignore all of those actions in terms of gameplay, but will replicate and federate them like any other AP system would
next TODOs
inbox/outbox handlers