git-next/crates/server-actor/src/handlers/receive_server_config.rs
Paul Campbell 681b2c4c10
All checks were successful
Rust / build (push) Successful in 1m46s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
refactor: split messages and handlers for server-actor
2024-07-11 19:19:01 +01:00

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,
);
}
}