mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 02:38:18 -07:00
add error handling for register_appservice too
This commit is contained in:
parent
da7b55b39c
commit
8f69f02e59
@ -109,7 +109,18 @@ impl Admin {
|
||||
}
|
||||
}
|
||||
AdminCommand::RegisterAppservice(yaml) => {
|
||||
guard.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
||||
match guard.appservice.register_appservice(yaml) {
|
||||
Ok(Some(id)) => {
|
||||
let msg: String = format!("OK. Appservice {} created", id);
|
||||
send_message(RoomMessageEventContent::text_plain(msg), guard, &state_lock);
|
||||
}
|
||||
Ok(None) => {
|
||||
send_message(RoomMessageEventContent::text_plain("WARN. Appservice created, but its ID was not returned!"), guard, &state_lock);
|
||||
}
|
||||
Err(_) => {
|
||||
send_message(RoomMessageEventContent::text_plain("ERR: Failed register appservice. Check server log"), guard, &state_lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
AdminCommand::UnregisterAppservice(service_name) => {
|
||||
if let Ok(_) = guard.appservice.unregister_appservice(&service_name) {
|
||||
|
@ -12,7 +12,7 @@ pub struct Appservice {
|
||||
}
|
||||
|
||||
impl Appservice {
|
||||
pub fn register_appservice(&self, yaml: serde_yaml::Value) -> Result<()> {
|
||||
pub fn register_appservice(&self, yaml: serde_yaml::Value) -> Result<Option<String>> {
|
||||
// TODO: Rumaify
|
||||
let id = yaml.get("id").unwrap().as_str().unwrap();
|
||||
self.id_appserviceregistrations.insert(
|
||||
@ -24,7 +24,7 @@ impl Appservice {
|
||||
.unwrap()
|
||||
.insert(id.to_owned(), yaml);
|
||||
|
||||
Ok(())
|
||||
Ok(Some(id.to_owned()))
|
||||
}
|
||||
|
||||
/// Remove an appservice registration
|
||||
|
Loading…
Reference in New Issue
Block a user