From 9e5e7419894bf2216199e2976cc6a6887760ccbb Mon Sep 17 00:00:00 2001 From: LDA Date: Sun, 14 Jul 2024 12:01:07 +0200 Subject: [PATCH] [MOD] Do NOT JUST RANDOMLY BRIDGE PLUMBED MUCS See README.MD for further thoughts that shall eventually be implemented. Still need to deal with MUC/room "consent". PM'ing the MUC owner with a form/using commands may be a nice course of action for that. --- README.MD | 11 +++++++++++ src/Commands/Plumb.c | 15 +-------------- src/Routes/UserAck.c | 12 ++++++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.MD b/README.MD index 58f7ebc..b1f5005 100644 --- a/README.MD +++ b/README.MD @@ -37,10 +37,21 @@ TODO ## TODOS - Mess with Cytoplasm to make it have support for something like Berkeley DB as an *optional* dependency. This should increase reliability and speed for anyone. + - Nesting might be an issue we'll need to deal with. libdb and Berkley DB + seem to lack support for them. If we can shove entries at specific indices, + we _might_ just manage to get some system that can at least emulate that, + and hopefully be reasonably faster than the filesystem, with some added + reliability. + - PROPER FUCKING AVATARS XEP-0084 IS THE WORST PIECE OF SHIT KNOWN TO MAN. If any Jabberbros want to look at terrible code/XML and suggest things to have *proper* avatar support, I'm all in. +- Consider making room/MUC admins/owners be able to plumb instead of it being +restricted to Parsee admins, with permission from MUC owners, too + - Limiting to admins may be a way to "control" consent for both, but this is + only if Parsee admins are good-willed, which we must assume such statment to + be false by default. - Look at XEPS-TBD.TXT for XEPs to be done - Achievements ### Why? diff --git a/src/Commands/Plumb.c b/src/Commands/Plumb.c index de2e417..d7b3ba0 100644 --- a/src/Commands/Plumb.c +++ b/src/Commands/Plumb.c @@ -24,51 +24,40 @@ CommandHead(CmdPlumb, cmd, argp) BotRequired(room); /* Check MUC viability */ - Log(LOG_INFO, "BAR1"); if (ParseeManageBan(args->data, muc, NULL)) { ReplySprintf("MUC '%s' is not allowed on this bridge.", muc); - Log(LOG_INFO, "BAR1F"); goto end; } - Log(LOG_INFO, "BAR2"); if (!XMPPQueryMUC(args->data->jabber, muc, &info)) { ReplySprintf("MUC '%s' does not exist.", muc); - Log(LOG_INFO, "BAR2F"); goto end; } - Log(LOG_INFO, "BAR3"); if ((chat_id = ParseeGetFromMUCID(args->data, muc))) { + ReplySprintf("MUC '%s' is already mapped to %s.", muc, chat_id); Free(chat_id); chat_id = NULL; - ReplySprintf("MUC '%s' is already mapped.", muc); - Log(LOG_INFO, "BAR3F"); goto end; } - Log(LOG_INFO, "FOO"); /* Check room viability */ room_id = ASJoin(args->data->config, room, NULL); if (!room_id) { ReplySprintf("Room '%s' does not exist.", room); - Log(LOG_INFO, "FOO2"); goto end; } - Log(LOG_INFO, "FOO3"); if ((chat_id = ParseeGetFromRoomID(args->data, room_id))) { Free(chat_id); chat_id = NULL; ReplySprintf("Room '%s' is already mapped.", room); - Log(LOG_INFO, "FOO4"); goto end; } - Log(LOG_INFO, "FOO5"); chat_id = ParseePushMUC(args->data, room_id, muc); if (chat_id) { @@ -77,11 +66,9 @@ CommandHead(CmdPlumb, cmd, argp) Free(rev); } - Log(LOG_INFO, "FOO6"); ReplySprintf("Plumbed '%s'", muc); end: - Log(LOG_INFO, "End."); BotDestroy(); Free(chat_id); Free(room_id); diff --git a/src/Routes/UserAck.c b/src/Routes/UserAck.c index 0c2d548..65b040f 100644 --- a/src/Routes/UserAck.c +++ b/src/Routes/UserAck.c @@ -85,6 +85,18 @@ RouteHead(RouteRoomAck, arr, argp) ); goto end; } + if ((chatid = ParseeGetFromMUCID(args->data, muc))) + { + /* TODO: Should we map the plumbed MUC? */ + Free(chatid); + chatid = NULL; + HttpResponseStatus(args->ctx, HTTP_METHOD_NOT_ALLOWED); + response = MatrixCreateError( + "M_UNRECOGNIZED", + "Room is already plumbed" + ); + goto end; + } creator = StrConcat( 4, "@", args->data->config->sender_localpart, ":",