Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

807 B
Raw Blame
use anyhow::{Context, Result};
use channels::domain::models::ParticipantRole;
use uuid::Uuid;

pub struct AddParticipantOptions<'a> {
    pub channel_id: &'a Uuid,
    pub user_id: &'a str,
    pub participant_role: Option<ParticipantRole>,
}

pub async fn add_participant<'e, 'a, E>(
    executor: E,
    options: AddParticipantOptions<'a>,
) -> Result<()>
where
    E: sqlx::Executor<'e, Database = sqlx::Postgres>,
{
    sqlx::query!(
        r#"
            INSERT INTO comms_channel_participants (channel_id, user_id, role)
            VALUES ($1, $2, $3)
        "#,
        options.channel_id,
        options.user_id,
        options.participant_role.unwrap_or_default() as ParticipantRole
    )
    .execute(executor)
    .await
    .context("unable to add participant to channel")?;

    Ok(())
}