38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
use actix::prelude::*;
|
|
|
|
use crate::{
|
|
messages::{ReceiveServerConfig, ReceiveValidServerConfig, ValidServerConfig},
|
|
Server,
|
|
};
|
|
|
|
impl Handler<ReceiveServerConfig> for Server {
|
|
type Result = ();
|
|
|
|
#[allow(clippy::cognitive_complexity)]
|
|
fn handle(&mut self, msg: ReceiveServerConfig, ctx: &mut Self::Context) -> Self::Result {
|
|
tracing::info!("recieved server config");
|
|
let Ok(socket_addr) = msg.http() else {
|
|
tracing::error!("Unable to parse http.addr");
|
|
return;
|
|
};
|
|
|
|
let Some(server_storage) = self.server_storage(&msg) else {
|
|
tracing::error!("Server storage not available");
|
|
return;
|
|
};
|
|
|
|
if msg.webhook().base_url().ends_with('/') {
|
|
tracing::error!("webhook.url must not end with a '/'");
|
|
return;
|
|
}
|
|
|
|
self.do_send(
|
|
ReceiveValidServerConfig::new(ValidServerConfig::new(
|
|
msg.unwrap(),
|
|
socket_addr,
|
|
server_storage,
|
|
)),
|
|
ctx,
|
|
);
|
|
}
|
|
}
|