Add support for merge request events

This commit is contained in:
2023-09-15 12:21:02 -07:00
parent b1337d3599
commit 8edb8a6a4a
3 changed files with 293 additions and 7 deletions

View File

@ -22,6 +22,8 @@ use matrix_sdk::{
};
use warp::Filter;
use crate::event::MergeRequestAction;
async fn build_sync_settings(matrix_client: &Client) -> SyncSettings {
let mut settings = SyncSettings::default().timeout(Duration::from_secs(30));
if let Some(token) = matrix_client.sync_token().await {
@ -125,6 +127,12 @@ async fn handle_gitlab_event(
room_id: &OwnedRoomOrAliasId,
matrix_client: &Client,
) -> anyhow::Result<()> {
if let GitlabEvent::MergeRequest { object_attributes, .. } = &event {
if object_attributes.action == MergeRequestAction::Other {
return Ok(());
}
}
let room = ensure_matrix_room_joined(matrix_client, room_id).await?;
let msg = build_gitlab_message(&event);
debug!("Sending message to {}: {}", room_id, msg);