Пример #1
0
def get_rooms(user_id: str):
    try:
        rooms = logic.get_user_room(user_id)
    except:
        raise room_errors.IdFormatError()

    return rooms
Пример #2
0
def room_update(room_id: str, room_name: str, avatar: str):
    try:
        logic.check_room_exists(room_id)
    except:
        raise room_errors.IdFormatError()

    return logic.update_room(room_id, room_name, avatar)
Пример #3
0
def remove_room(room_id: str):
    try:
        room = room_logic.check_room_exists(room_id)
    except:
        raise room_errors.IdFormatError()
    if room:
        return logic.room_delete(room_id)

    return False
Пример #4
0
def invite_member(room_id: str, member_name: str):
    try:
        member_id = get_user_id(member_name)
        if not member_id:
            raise user_errors.NotFoundError(obj=f"User {member_name}")
        member = logic.check_member_exists(room_id, member_id)
    except Exception as e:
        raise room_errors.IdFormatError()
    if member:
        raise room_errors.ExistingError(obj=f"Member {member_name}")
    return logic.invite_member(room_id, member_name)
Пример #5
0
def save_message(content: str,
                 sender_id: Optional[str] = None,
                 room_id: Optional[str] = None):
    try:
        check_user_exist(sender_id)
    except:
        raise user_errors.IdFormatError()

    try:
        check_room_exists(room_id)
    except:
        raise room_errors.IdFormatError()

    return logic.save_messages(content, sender_id, room_id)