Allow setting an avatar image for the bot's account
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -41,13 +41,25 @@ async fn run() -> anyhow::Result<()> {
|
||||
.ok_or_else(|| anyhow!("Config file should be passed as only parameter"))?;
|
||||
let mut config = config::load(config_path).await?;
|
||||
|
||||
let matrix_client = matrix::connect(&config).await.context("Failed to connect to Matrix")?;
|
||||
let mut join_handles = Vec::default();
|
||||
|
||||
let handles = if let Some(mail_archive) = config.mail_archive.take() {
|
||||
let matrix_client = matrix::connect(&config).await.context("Failed to connect to Matrix")?;
|
||||
if let Some(avatar_path) = config.avatar_image_path {
|
||||
let matrix_client = matrix_client.clone();
|
||||
let handle = tokio::spawn(async move {
|
||||
if let Err(err) = matrix::set_avatar_if_needed(&matrix_client, avatar_path).await {
|
||||
warn!("Failed to set matrix avatar: {err}");
|
||||
}
|
||||
});
|
||||
join_handles.push(handle);
|
||||
}
|
||||
|
||||
let mail_join_handles = if let Some(mail_archive) = config.mail_archive.take() {
|
||||
mail_archive::start_polling(mail_archive, matrix_client.clone())?
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
join_handles.extend(mail_join_handles);
|
||||
|
||||
if let Some(gitlab_webhook) = config.gitlab_webhook.take() {
|
||||
let gitlab = gitlab_webhook::build_route(gitlab_webhook, matrix_client.clone());
|
||||
@@ -60,7 +72,7 @@ async fn run() -> anyhow::Result<()> {
|
||||
axum::serve(listener, gitlab).await?;
|
||||
}
|
||||
|
||||
join_all(handles).await;
|
||||
join_all(join_handles).await;
|
||||
|
||||
error!("No functionality is configured; exiting");
|
||||
exit(1);
|
||||
|
Reference in New Issue
Block a user