mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-19 12:40:10 +00:00
Return the ID of the appservice that was created by register_appservice
This commit is contained in:
parent
78502aa6b1
commit
28d3b348d2
@ -110,13 +110,10 @@ impl Admin {
|
|||||||
}
|
}
|
||||||
AdminCommand::RegisterAppservice(yaml) => {
|
AdminCommand::RegisterAppservice(yaml) => {
|
||||||
match guard.appservice.register_appservice(yaml) {
|
match guard.appservice.register_appservice(yaml) {
|
||||||
Ok(Some(id)) => {
|
Ok(id) => {
|
||||||
let msg: String = format!("OK. Appservice {} created", id);
|
let msg: String = format!("OK. Appservice {} created", id);
|
||||||
send_message(RoomMessageEventContent::text_plain(msg), guard, &state_lock);
|
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(_) => {
|
Err(_) => {
|
||||||
send_message(RoomMessageEventContent::text_plain("ERR: Failed register appservice. Check server log"), guard, &state_lock);
|
send_message(RoomMessageEventContent::text_plain("ERR: Failed register appservice. Check server log"), guard, &state_lock);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,9 @@ pub struct Appservice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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
|
// TODO: Rumaify
|
||||||
let id = yaml.get("id").unwrap().as_str().unwrap();
|
let id = yaml.get("id").unwrap().as_str().unwrap();
|
||||||
self.id_appserviceregistrations.insert(
|
self.id_appserviceregistrations.insert(
|
||||||
@ -22,9 +24,9 @@ impl Appservice {
|
|||||||
self.cached_registrations
|
self.cached_registrations
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.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
|
/// Remove an appservice registration
|
||||||
|
Loading…
Reference in New Issue
Block a user