Compare commits
No commits in common. "7c24e2564f45d907041081dc196990c03c6eb59f" and "5a65c713bd9455fc53c34e4821c6622e3d9bf87d" have entirely different histories.
7c24e2564f
...
5a65c713bd
10
src/main.rs
10
src/main.rs
@ -154,7 +154,7 @@ async fn run() -> anyhow::Result<()> {
|
||||
.and(warp::post())
|
||||
.and(warp::header::<String>("x-gitlab-token"))
|
||||
.and(warp::body::json())
|
||||
.then(move |token: String, event: event::GitlabEvent| {
|
||||
.and_then(move |token: String, event: event::GitlabEvent| {
|
||||
let config = Arc::clone(&config);
|
||||
let matrix_client = matrix_client.clone();
|
||||
|
||||
@ -164,22 +164,22 @@ async fn run() -> anyhow::Result<()> {
|
||||
if let Some(repo_config) = config.repo_configs.get(&config_key) {
|
||||
if !constant_time_eq(token.as_bytes(), repo_config.token.as_bytes()) {
|
||||
warn!("Invalid token for repo '{}'", config_key);
|
||||
warp::reply::with_status("Invalid token", StatusCode::FORBIDDEN)
|
||||
Err(warp::reject::reject())
|
||||
} else {
|
||||
debug!("payload: {:?}", event);
|
||||
if let Some(room) = repo_config.room.as_ref().or(config.default_room.as_ref()) {
|
||||
if let Err(err) = handle_gitlab_event(event, &room, &matrix_client).await {
|
||||
warn!("Failed to handle payload: {}", err);
|
||||
}
|
||||
warp::reply::with_status("OK", StatusCode::OK)
|
||||
Ok(warp::reply::with_status("OK", StatusCode::OK))
|
||||
} else {
|
||||
info!("Channel not configured for repo '{}'", config_key);
|
||||
warp::reply::with_status("Matrix room not configured for repo", StatusCode::NOT_FOUND)
|
||||
Err(warp::reject::reject())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info!("Repo '{}' unconfigured", config_key);
|
||||
warp::reply::with_status("Repo not configured", StatusCode::NOT_FOUND)
|
||||
Err(warp::reject::reject())
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user