1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-09 06:11:04 +01:00

Merge branch 'fix-admin-self-commands' into 'next'

Fix admin room processing commands from its own messages

See merge request famedly/conduit!293
This commit is contained in:
Timo Kösters 2022-02-12 12:27:57 +00:00
commit d6b9874b35

View file

@ -1477,17 +1477,18 @@ impl Rooms {
self.tokenids.insert_batch(&mut batch)?; self.tokenids.insert_batch(&mut batch)?;
if body.starts_with(&format!("@conduit:{}: ", db.globals.server_name())) let admin_room = self.id_from_alias(
&& self
.id_from_alias(
<&RoomAliasId>::try_from( <&RoomAliasId>::try_from(
format!("#admins:{}", db.globals.server_name()).as_str(), format!("#admins:{}", db.globals.server_name()).as_str(),
) )
.expect("#admins:server_name is a valid room alias"), .expect("#admins:server_name is a valid room alias"),
)? )?;
.as_ref() let server_user = format!("@conduit:{}", db.globals.server_name());
== Some(&pdu.room_id)
{ let to_conduit = body.starts_with(&format!("{}: ", server_user));
let from_conduit = pdu.sender == server_user;
if to_conduit && !from_conduit && admin_room.as_ref() == Some(&pdu.room_id) {
db.admin.process_message(body.to_string()); db.admin.process_message(body.to_string());
} }
} }