def add_user_to_conversation( user_id: str, user_email: str, channel_id: str, incident_id: int, action: dict, db_session=None, slack_client=None, ): """Adds a user to a conversation.""" incident = incident_service.get(db_session=db_session, incident_id=incident_id) if not incident: message = "Sorry, we cannot add you to this incident it does not exist." dispatch_slack_service.send_ephemeral_message(slack_client, channel_id, user_id, message) elif incident.status == IncidentStatus.closed: message = f"Sorry, we cannot add you to a closed incident. Please reach out to the incident commander ({incident.commander.individual.name}) for details." dispatch_slack_service.send_ephemeral_message(slack_client, channel_id, user_id, message) else: dispatch_slack_service.add_users_to_conversation( slack_client, incident.conversation.channel_id, [user_id]) message = f"Success! We've added you to incident {incident.name}. Please check your side bar for the new channel." dispatch_slack_service.send_ephemeral_message(slack_client, channel_id, user_id, message)
def add_user_to_conversation(user_email: str, incident_id: int, action: dict, db_session=None): """Adds a user to a conversation.""" incident = incident_service.get(db_session=db_session, incident_id=incident_id) user_id = dispatch_slack_service.resolve_user(slack_client, user_email)["id"] dispatch_slack_service.add_users_to_conversation( slack_client, incident.conversation.channel_id, user_id)
def add_user_to_conversation( user_id: str, user_email: str, incident_id: int, action: dict, db_session=None ): """Adds a user to a conversation.""" incident = incident_service.get(db_session=db_session, incident_id=incident_id) if incident.status == IncidentStatus.closed: message = f"Sorry, we cannot add you to a closed incident. Please reach out to the incident commander ({incident.commander.name}) for details." dispatch_slack_service.send_ephemeral_message( slack_client, action["container"]["channel_id"], user_id, message ) else: dispatch_slack_service.add_users_to_conversation( slack_client, incident.conversation.channel_id, [user_id] )