Exemplo n.º 1
0
    def send_join_request(self, roomname: str, username: str) -> None:
        """ Send a join request to the sepcified room
        Args:
            roomname (str): Name of the room to join
            username (str): User that is to requesting to join
        """

        get_members_query = Query.get_room_members(roomname)
        room_members: str = self.db.read_execute_query(get_members_query)[0][0]
        room_members_list = room_members.split()

        if username in room_members_list:
            return

        try:
            get_pending_requests_query = Query.get_pending_requests(roomname)
            pending_requests: str = self.db.read_execute_query(
                get_pending_requests_query)[0][0]
            room_request_query = Query.room_request(roomname, username,
                                                    pending_requests)
            self.db.execute_query(room_request_query)

        except IndexError:
            room_request_query = Query.room_request(roomname, username, "")
            self.db.execute_query(room_request_query)
Exemplo n.º 2
0
 def _remove(updated_pending_requests):
     """Remove username from pending request list"""
     remove_member_from_pending_query = Query.room_request(
         roomname, "", updated_pending_requests)
     self.db.execute_query(remove_member_from_pending_query)