[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.
This commit is contained in:
LDA 2024-07-14 12:01:07 +02:00
commit 9e5e741989
3 changed files with 24 additions and 14 deletions

View file

@ -37,10 +37,21 @@ TODO
## TODOS ## TODOS
- Mess with Cytoplasm to make it have support for something like Berkeley DB as - 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. 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 - PROPER FUCKING AVATARS
XEP-0084 IS THE WORST PIECE OF SHIT KNOWN TO MAN. If any Jabberbros want to 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, look at terrible code/XML and suggest things to have *proper* avatar support,
I'm all in. 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 - Look at XEPS-TBD.TXT for XEPs to be done
- Achievements - Achievements
### Why? ### Why?

View file

@ -24,51 +24,40 @@ CommandHead(CmdPlumb, cmd, argp)
BotRequired(room); BotRequired(room);
/* Check MUC viability */ /* Check MUC viability */
Log(LOG_INFO, "BAR1");
if (ParseeManageBan(args->data, muc, NULL)) if (ParseeManageBan(args->data, muc, NULL))
{ {
ReplySprintf("MUC '%s' is not allowed on this bridge.", muc); ReplySprintf("MUC '%s' is not allowed on this bridge.", muc);
Log(LOG_INFO, "BAR1F");
goto end; goto end;
} }
Log(LOG_INFO, "BAR2");
if (!XMPPQueryMUC(args->data->jabber, muc, &info)) if (!XMPPQueryMUC(args->data->jabber, muc, &info))
{ {
ReplySprintf("MUC '%s' does not exist.", muc); ReplySprintf("MUC '%s' does not exist.", muc);
Log(LOG_INFO, "BAR2F");
goto end; goto end;
} }
Log(LOG_INFO, "BAR3");
if ((chat_id = ParseeGetFromMUCID(args->data, muc))) if ((chat_id = ParseeGetFromMUCID(args->data, muc)))
{ {
ReplySprintf("MUC '%s' is already mapped to %s.", muc, chat_id);
Free(chat_id); Free(chat_id);
chat_id = NULL; chat_id = NULL;
ReplySprintf("MUC '%s' is already mapped.", muc);
Log(LOG_INFO, "BAR3F");
goto end; goto end;
} }
Log(LOG_INFO, "FOO");
/* Check room viability */ /* Check room viability */
room_id = ASJoin(args->data->config, room, NULL); room_id = ASJoin(args->data->config, room, NULL);
if (!room_id) if (!room_id)
{ {
ReplySprintf("Room '%s' does not exist.", room); ReplySprintf("Room '%s' does not exist.", room);
Log(LOG_INFO, "FOO2");
goto end; goto end;
} }
Log(LOG_INFO, "FOO3");
if ((chat_id = ParseeGetFromRoomID(args->data, room_id))) if ((chat_id = ParseeGetFromRoomID(args->data, room_id)))
{ {
Free(chat_id); Free(chat_id);
chat_id = NULL; chat_id = NULL;
ReplySprintf("Room '%s' is already mapped.", room); ReplySprintf("Room '%s' is already mapped.", room);
Log(LOG_INFO, "FOO4");
goto end; goto end;
} }
Log(LOG_INFO, "FOO5");
chat_id = ParseePushMUC(args->data, room_id, muc); chat_id = ParseePushMUC(args->data, room_id, muc);
if (chat_id) if (chat_id)
{ {
@ -77,11 +66,9 @@ CommandHead(CmdPlumb, cmd, argp)
Free(rev); Free(rev);
} }
Log(LOG_INFO, "FOO6");
ReplySprintf("Plumbed '%s'", muc); ReplySprintf("Plumbed '%s'", muc);
end: end:
Log(LOG_INFO, "End.");
BotDestroy(); BotDestroy();
Free(chat_id); Free(chat_id);
Free(room_id); Free(room_id);

View file

@ -85,6 +85,18 @@ RouteHead(RouteRoomAck, arr, argp)
); );
goto end; 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( creator = StrConcat(
4, 4,
"@", args->data->config->sender_localpart, ":", "@", args->data->config->sender_localpart, ":",