Return the ID of the appservice that was created by register_appservice
This commit is contained in:
parent
8f69f02e59
commit
e24d75cffc
2 changed files with 6 additions and 7 deletions
|
@ -110,13 +110,10 @@ impl Admin {
|
|||
}
|
||||
AdminCommand::RegisterAppservice(yaml) => {
|
||||
match guard.appservice.register_appservice(yaml) {
|
||||
Ok(Some(id)) => {
|
||||
Ok(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);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ pub struct Appservice {
|
|||
}
|
||||
|
||||
impl Appservice {
|
||||
pub fn register_appservice(&self, yaml: serde_yaml::Value) -> Result<Option<String>> {
|
||||
/// Registers an appservice and returns the ID to the caller
|
||||
///
|
||||
pub fn register_appservice(&self, yaml: serde_yaml::Value) -> Result<String> {
|
||||
// TODO: Rumaify
|
||||
let id = yaml.get("id").unwrap().as_str().unwrap();
|
||||
self.id_appserviceregistrations.insert(
|
||||
|
@ -22,9 +24,9 @@ impl Appservice {
|
|||
self.cached_registrations
|
||||
.write()
|
||||
.unwrap()
|
||||
.insert(id.to_owned(), yaml);
|
||||
.insert(id.to_owned(), yaml.to_owned());
|
||||
|
||||
Ok(Some(id.to_owned()))
|
||||
Ok(id.to_owned())
|
||||
}
|
||||
|
||||
/// Remove an appservice registration
|
||||
|
|
Loading…
Add table
Reference in a new issue