Post A81the2tFujeC2UEq0 by cy@fedicy.allowed.org
(DIR) More posts by cy@fedicy.allowed.org
(DIR) Post #A81the2tFujeC2UEq0 by cy@fedicy.allowed.org
2021-06-07T03:18:26.219168Z
0 likes, 0 repeats
There has got to be a simpler way to do this. Just to do webfinger, currently:the dispatcher has a webfinger function which suspends the connection and calls search_webfinger in peepsthe peeps module has a search_webfinger function, which locks the database and sends a database query, then schedules wait_for_webfinger to run in a worker thread, so it can continue serving web requests.the peeps module has a wait_for_webfinger function that blocks until the database returns a result, unlocks the database, then parses the fields out of the result, and calls peeps_webfinger_hook, with those fields and a boolean for whether there was a row or not.the dispatcher module has to define peeps_webfinger_hook, which extracts the fields from the webfinger result, then #includes a template file that queues a response based on those fields, then resumes the connection.So if I want to add support for a user profile URI, I have to make user_profile, and peeps_user_profile_hook in dispatch, and a search_user_profile function and a wait_for_user_profile callback function and a template to output a user profile. There would be a slightly different database query, and a different template file, and otherwise the exact same copypasta boilerplate code with user_profile substituted everywhere for webfinger. Bouncing between modules with callbacks thrown in just to make sure you can’t follow the program’s execution. Then I have to do the same thing for 34 more URI patterns. It’s already an unreadable mess just implementing webfinger!