Add ability to remove an appservice
This commit is contained in:
parent
9b57c89df6
commit
7857da8a0b
4 changed files with 30 additions and 0 deletions
|
@ -42,6 +42,14 @@ could help.
|
|||
|
||||
## Appservice-specific instructions
|
||||
|
||||
### Remove an appservice
|
||||
|
||||
To remove an appservice go to your admin room and execute
|
||||
|
||||
```@conduit:your.server.name: unregister_appservice <name>```
|
||||
|
||||
where `<name>` one of the output of `list_appservices`.
|
||||
|
||||
### Tested appservices
|
||||
|
||||
These appservices have been tested and work with Conduit without any extra steps:
|
||||
|
|
|
@ -12,6 +12,7 @@ use tracing::warn;
|
|||
|
||||
pub enum AdminCommand {
|
||||
RegisterAppservice(serde_yaml::Value),
|
||||
UnregisterAppservice(String),
|
||||
ListAppservices,
|
||||
SendMessage(RoomMessageEventContent),
|
||||
}
|
||||
|
@ -96,6 +97,9 @@ impl Admin {
|
|||
AdminCommand::RegisterAppservice(yaml) => {
|
||||
guard.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
||||
}
|
||||
AdminCommand::UnregisterAppservice(service_name) => {
|
||||
guard.appservice.unregister_appservice(&service_name).unwrap(); // TODO: see above
|
||||
}
|
||||
AdminCommand::ListAppservices => {
|
||||
if let Ok(appservices) = guard.appservice.iter_ids().map(|ids| ids.collect::<Vec<_>>()) {
|
||||
let count = appservices.len();
|
||||
|
|
|
@ -27,6 +27,15 @@ impl Appservice {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an appservice registration
|
||||
* service_name is the name you send to register the service
|
||||
*/
|
||||
pub fn unregister_appservice(&self, service_name: &str) -> Result<()> {
|
||||
self.id_appserviceregistrations.remove(service_name.as_bytes())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_registration(&self, id: &str) -> Result<Option<serde_yaml::Value>> {
|
||||
self.cached_registrations
|
||||
.read()
|
||||
|
|
|
@ -1528,6 +1528,15 @@ impl Rooms {
|
|||
));
|
||||
}
|
||||
}
|
||||
"unregister_appservice" => {
|
||||
if args.len() == 1 {
|
||||
db.admin.send(AdminCommand::UnregisterAppservice(args[0].to_owned()));
|
||||
} else {
|
||||
db.admin.send(AdminCommand::SendMessage(
|
||||
RoomMessageEventContent::text_plain("Missing appservice identifier"),
|
||||
));
|
||||
}
|
||||
}
|
||||
"list_appservices" => {
|
||||
db.admin.send(AdminCommand::ListAppservices);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue