Example #1
0
def incident_remove_participant_flow(
    user_email: str, incident_id: int, event: dict = None, db_session=None
):
    """Runs the remove participant flow."""
    # we load the incident instance
    incident = incident_service.get(db_session=db_session, incident_id=incident_id)

    if user_email == incident.commander.email:
        # we add the incident commander to the conversation again
        add_participant_to_conversation(user_email, incident_id, db_session)

        # we send a notification to the channel
        send_incident_commander_readded_notification(incident_id, db_session)
    else:
        # we remove the participant from the incident
        participant_flows.remove_participant(user_email, incident_id, db_session)
Example #2
0
def job_remove_participant_flow(user_email: str,
                                job_id: int,
                                event: dict = None,
                                db_session=None):
    """Runs the remove participant flow."""
    # we load the job instance
    job = job_service.get(db_session=db_session, job_id=job_id)

    if user_email == job.commander.code:
        # we add the job commander to the conversation again
        add_participant_to_conversation(user_email, job_id, db_session)

        # we send a notification to the channel
        send_job_commander_readded_notification(job_id, db_session)
    else:
        # we remove the participant from the job
        participant_flows.remove_participant(user_email, job_id, db_session)
Example #3
0
def incident_remove_participant_flow(user_email: str, incident_id: int, db_session=None):
    """Runs the remove participant flow."""
    # we load the incident instance
    incident = incident_service.get(db_session=db_session, incident_id=incident_id)

    if user_email == incident.commander.email:
        # we add the incident commander to the conversation again
        add_participant_to_conversation(incident.conversation.channel_id, user_email)

        # we send a notification to the channel
        send_incident_commander_readded_notification(incident)

        log.debug(
            f"Incident Commander {incident.commander.name} has been re-added to conversation {incident.conversation.channel_id}."
        )
    else:
        # we remove the participant from the incident
        participant_flows.remove_participant(user_email, incident_id, db_session)