def channel_join(token, channel_id):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="you must be logged in to join of a channel!")

    # CHECK THE VALIDITY

    u_id = token_to_u_ID(loggedInUsersDB, token)
    u_id = int(u_id)
    channel_id = int(channel_id)
    first_name = get_firstName(u_id)
    last_name = get_lastName(u_id)
    profile_img_url = get_url(u_id)

    permission = get_user_permission(u_id)
    if permission < MEMBER():
        return join_special(channelsDB, channel_id, u_id, first_name,
                            last_name, profile_img_url)

    else:
        return join_nonSpecial(channelsDB, channel_id, u_id, first_name,
                               last_name, profile_img_url)

    raise ValueError(description="Invalid Channel ID")
예제 #2
0
def message_send_later(token, channel_id, message, time_to_send):
    messageQueue = get_global_messageQueue()

    time_to_send = float(time_to_send)
    time_to_send = int(time_to_send)

    if len(message) > 1000:
        raise ValueError(description="Message too long")

    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()
    messageQueue = get_global_messageQueue()

    channel_id = int(channel_id)

    u_id = token_to_u_ID(loggedInUsersDB, token)

    if not is_inChannel(
            channelsDB=channelsDB, u_id=u_id, channel_id=channel_id):
        raise AccessError(
            description='You must join the channel to send a message!')

    timeNow = (datetime.datetime.utcnow() -
               datetime.timedelta(seconds=1)).replace(
                   tzinfo=timezone.utc).timestamp()

    if time_to_send < timeNow:
        raise ValueError(description='You selected a time in the past!')

    length = len(messageQueue) + 1
    msgElement = create_message_later(u_id, message, time_to_send, channel_id)
    messageQueue.append(msgElement)
    # This is just temporary; it will get updated once the message actually sends
    return {'message_id': length}
예제 #3
0
def message_unreact(token, message_id, react_id):
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()
    message_id = int(message_id)
    react_id = int(react_id)

    check_reaction(react_id)

    u_id = token_to_u_ID(loggedInUsersDB, token)
    channel = get_channel(channelsDB, message_id)

    if not is_inChannel(channelsDB=channelsDB,
                        u_id=u_id,
                        channel_id=channel['channel_id']):
        raise AccessError(
            description='You must be in the channel to unreact to a message!')

    for message in channel['messagesListDict']:
        if message['message_id'] == message_id:
            for reaction in message['reacts']:
                if reaction['react_id'] == react_id:
                    if u_id in reaction['u_ids']:
                        reaction['u_ids'].remove(u_id)
                        reaction['is_this_user_reacted'] = False
                        for userID in reaction['u_ids']:
                            if get_user_permission(userID) < 2:
                                reaction['is_this_user_reacted'] = True
                        return
                    else:
                        raise ValueError(
                            description='You cant unreact a unreacted message!'
                        )
    raise ValueError("Error unreacting")
def standup_send(token, channel_id, message):
	registeredUsersDB = get_global_registeredUsers()
	loggedInUsersDB = get_global_loggedInUsers()
	channelsDB = get_global_existingChannels()

	email = token_to_email(token)
	if not is_loggedIn(loggedInUsersDB, email):
		raise AccessError(description="Unauthorised Access")	
	
	channel_id = int(channel_id)
	channel = getChannel(channelsDB, channel_id)
	u_id = token_to_u_ID(loggedInUsersDB, token)

	if not channel['is_standup_running']:
		raise ValueError(description="No standup is running")
	if len(message) > 1000: 
		raise ValueError(description="Message too long")


	if not is_inChannel(channelsDB,channel_id, u_id):
		raise AccessError(description='You must be in a channel to send a standup')


	handle = get_user_handle(registeredUsersDB, u_id)

	message = handle + ' : ' + message +'\n'
	for standup in channel['standups']:
		if standup['isActive']:

			standup['messages'] += message
			
	return {}
def channels_listall(token):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to view a list of channels!")

    if not channelsDB:
        return {'channels': []}

    u_id = token_to_u_ID(registeredUsersDB, token)
    u_id = int(u_id)
    pID = get_user_permission(u_id)

    channelListDict = []
    for channel in channelsDB:
        if pID < MEMBER():
            channelDict = channel_name_id_dictionary(channel)
            channelListDict.append(channelDict)

        elif channel['is_public']:
            channelDict = channel_name_id_dictionary(channel)
            channelListDict.append(channelDict)

    return {'channels': channelListDict}
def join_special(channelDatabaseListDict, channel_id, u_id, firstName,
                 lastName, profile_img_url):
    loggedInUsersDB = get_global_loggedInUsers()
    for channel in channelDatabaseListDict:
        if channel['channel_id'] == channel_id:
            found = False
            for owner in channel['owner_members']:
                if owner['u_id'] == u_id:
                    found = True

            if not found:
                user = {
                    'u_id': u_id,
                    'name_first': firstName,
                    'name_last': lastName,
                    'profile_img_url': profile_img_url
                }
                channel['owner_members'].append(user)

                for loggedinUser in loggedInUsersDB:
                    if loggedinUser['u_id'] == u_id:
                        channel['online_members'].append(user)

            save_channel()
            return {}
def add_to_channel(channelDatabaseListDict, ownerU_ID, nonMemberU_ID,
                   channel_id):

    loggedInUsersDB = get_global_loggedInUsers()

    nonMemberU_ID = int(nonMemberU_ID)
    channel_id = int(channel_id)
    ownerU_ID = int(ownerU_ID)
    firstName = get_firstName(nonMemberU_ID)
    lastName = get_lastName(nonMemberU_ID)
    profile_img_url = get_url(nonMemberU_ID)
    nonMemberP_ID = get_user_permission(nonMemberU_ID)

    if not is_inChannel(channelDatabaseListDict, channel_id, ownerU_ID):
        raise AccessError(
            description='You must be in the channel to invite other members')

    if nonMemberP_ID < MEMBER():
        temp = join_special(channelDatabaseListDict, channel_id, nonMemberU_ID,
                            firstName, lastName, profile_img_url)
        return
    else:
        temp = join_nonSpecial(channelDatabaseListDict, channel_id,
                               nonMemberU_ID, firstName, lastName,
                               profile_img_url)
        return
    raise ValueError(description="Unauthorised Access")
def join_nonSpecial(channelDatabaseListDict, channel_id, u_id, firstName,
                    lastName, profile_img_url):
    loggedInUsersDB = get_global_loggedInUsers()
    for channel in channelDatabaseListDict:
        if channel['channel_id'] == channel_id:
            if not channel['is_public']:
                raise AccessError(
                    description=
                    "You cant join a private channel; but you can get invited to one! Ask a friend to invite you!"
                )
            else:
                found = False
                for member in channel['other_members']:
                    if member['u_id'] == u_id:
                        found = True
                if not found:
                    user = {
                        'u_id': u_id,
                        'name_first': firstName,
                        'name_last': lastName,
                        'profile_img_url': profile_img_url
                    }
                    channel['other_members'].append(user)

                    for loggedinUser in loggedInUsersDB:
                        if loggedinUser['u_id'] == u_id:
                            channel['online_members'].append(user)

                save_channel()
                return {}
def channel_delete(token, channel_id):
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be in a channel to delete a channel!")

    u_id = token_to_u_ID(loggedInUsersDB, token)
    u_id = int(u_id)
    channel_id = int(channel_id)

    if not is_inChannel(
            u_id=u_id, channel_id=channel_id, channelsDB=channelsDB):
        raise AccessError(
            description='You must be in the channel to delete a channel!')

    for channel in channelsDB:
        if channel['channel_id'] == channel_id:
            for owner in channel['owner_members']:
                if u_id == owner['u_id']:
                    channelsDB.remove(channel)
                    save_channel()
                    return {}

    raise ValueError(description='You must be an owner to delete the channel!')
def channel_name_change(token, channel_id, name):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = load_channel()

    check_valid_channel_name(name)
    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to change the name of a channel!"
        )

    u_id = token_to_u_ID(loggedInUsersDB, token)
    u_id = int(u_id)
    channel_id = int(channel_id)
    if not is_inChannel(
            u_id=u_id, channel_id=channel_id, channelsDB=channelsDB):
        raise AccessError(
            description=
            'You must be in the channel to change the name of a channel!')
    for channel in channelsDB:
        if channel['channel_id'] == channel_id:
            for owner in channel['owner_members']:
                if u_id == owner['u_id']:
                    channel['name'] = name
                    save_channel()
                    return {}
    raise AccessError(
        description=
        'You must be an owner of the channel to change the name of the channel!'
    )
예제 #11
0
def users_all(token):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError("You must be logged in to view all users")
    userList = []
    for user in registeredUsersDB:
        userList.append(user)
    return {'users': userList}
def channel_addowner(token, channel_id, u_id):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="you must be logged in to add an owner to a channel!")

    ownerU_ID = token_to_u_ID(loggedInUsersDB, token)
    add_member_to_owner(channelsDB, ownerU_ID, u_id, channel_id)
    save_channel()
    return {}
예제 #13
0
def auth_logout(token):
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = load_channel()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        return {'is_success': False}

    u_id = get_u_ID(loggedInUsersDB, email)
    u_id = int(u_id)
    make_offline(channelsDB, u_id)

    logout_user(loggedInUsersDB, email, u_id)
    return {'is_success': True}
def channel_details(token, channel_id):
    registeredUsersDB = load_user()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = load_channel()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description=
            "You must be logged in to view the details of a channel!")

    u_id = token_to_u_ID(loggedInUsersDB, token)
    channelDictionary = get_channel_details(channelsDB, u_id, channel_id)
    save_channel()
    return channelDictionary
예제 #15
0
def user_profile(token, u_id):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)

    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to view a profile!")

    viewerID = token_to_u_ID(registeredUsersDB, token)

    userDictionary = get_user_profile(registeredUsersDB, u_id)
    save_registered_users()
    return userDictionary
def channel_leave(token, channel_id):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to leave a channel!")

    u_id = token_to_u_ID(loggedInUsersDB, token)
    u_id = int(u_id)
    channel_id = int(channel_id)
    remove_user_from_channel(channelsDB, u_id, channel_id)
    save_channel()
    return {}
def channels_list(token):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to view a list of channels!")

    u_id = token_to_u_ID(registeredUsersDB, token)
    if not channelsDB:
        return {'channels': []}

    channelListDict = listUserChannels(channelsDB, u_id)
    return {'channels': channelListDict}
예제 #18
0
def message_send(token, channel_id, message, time_sent):
    if len(message) > 1000:
        raise ValueError(description="Message too long")

    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    channel_id = int(channel_id)

    u_id = token_to_u_ID(loggedInUsersDB, token)

    if not is_inChannel(
            channelsDB=channelsDB, u_id=u_id, channel_id=channel_id):
        raise AccessError(
            description='You must join the channel to send a message!')
    return send_message_help(u_id, channel_id, message, time_sent)
예제 #19
0
def user_profiles_uploadphoto(token, img_url, x_start, y_start, x_end, y_end,
                              base):
    channelsDB = get_global_existingChannels()
    loggedInUsersDB = get_global_loggedInUsers()
    registeredUsersDB = get_global_registeredUsers()

    email = token_to_email(token)
    u_id = token_to_u_ID(registeredUsersDB, token)
    u_id = int(u_id)
    if not base:
        try:
            update_profile_photo(registeredUsersDB, channelsDB, u_id, img_url)
            return update_online_profile_photo(loggedInUsersDB, u_id, img_url)
        except:
            raise AccessError(description="Error uploading the photo")
    base = str(base)
    x_start = int(x_start)
    y_start = int(y_start)
    x_end = int(x_end)
    y_end = int(y_end)

    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError("You must be logged in to change your photo")
    try:
        request.urlopen(img_url)
    except:
        raise ValueError(
            description="Cannot open image URL. Please try other images")

    request.urlretrieve(img_url, f'frontend/prebundle/images/{u_id}.jpg')
    crop_image(f'frontend/prebundle/images/{u_id}.jpg', x_start, y_start,
               x_end,
               y_end).save(f'frontend/prebundle/images/cropped_{u_id}.jpg')
    port = base[-5:-1]
    port = int(port)
    port += 3000
    string = 'http://localhost:' + str(port) + '/'
    local_url = string + f'images/cropped_{u_id}.jpg'  #adding port and http to match the localhost'port'
    print(local_url, '\n\n\n\n\n\n\n\n\n\n\n')
    # UNTIL HERE ONLYhttp://localhost
    # DONT TOUCH THE CODE BELOW
    try:
        update_profile_photo(registeredUsersDB, channelsDB, u_id, local_url)
        return update_online_profile_photo(loggedInUsersDB, u_id, local_url)
    except:
        raise AccessError(description="Error uploading the photo")
예제 #20
0
def user_profile_sethandle(token, handle):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to change your handle")

    check_valid_handle(registeredUsersDB, handle)

    u_id = token_to_u_ID(registeredUsersDB, token)

    update_handle(registeredUsersDB, u_id, handle)
    save_registered_users()
    return {}
예제 #21
0
def user_setname(token, name_first, name_last):

    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in to change your name!")

    check_valid_name(name_first)
    check_valid_name(name_last)

    u_id = token_to_u_ID(registeredUsersDB, token)

    update_name(registeredUsersDB, channelsDB, u_id, name_first, name_last)
    return {}
def search(token, query_str):
	loggedInUsers = get_global_loggedInUsers()
	channelsDB = get_global_existingChannels()
	u_id = token_to_u_ID(loggedInUsers, token)
	messagesDictionary = {'messages':[]}
	for channel in channelsDB:
		for owner in channel['owner_members']:
			if owner['u_id'] == u_id:
				for message in channel['messagesListDict']:
					if query_str in message['message']:
						messagesDictionary['messages'].append(message)
					
		for member in channel['other_members']:
			if member['u_id'] == u_id:
				for message in channel['messagesListDict']:
					if query_str in message['message']:
						messagesDictionary['messages'].append(message)
					
	return messagesDictionary
예제 #23
0
def message_unpin(token, message_id):
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    message_id = int(message_id)
    u_id = token_to_u_ID(loggedInUsersDB, token)
    channel = get_channel(channelsDB, message_id)

    if not is_inChannel(channelsDB=channelsDB,
                        u_id=u_id,
                        channel_id=channel['channel_id']):
        raise AccessError(
            description='You must be in the channel to unpin a message!')

    for owner in channel['owner_members']:
        if u_id == owner['u_id']:
            return unpin_message(channel, message_id)
    for member in channel['other_members']:
        if u_id == member['u_id']:
            raise AccessError(
                description="You must be an owner of the channel to unpin!")
예제 #24
0
def auth_register(email, password, firstName, lastName):
    registeredUsersDB = load_user()
    loggedInUsersDB = get_global_loggedInUsers()
    check_valid_name(firstName)
    check_valid_name(lastName)
    check_valid_email(email)
    check_valid_password(password)

    # Converts the passed name into a propoer name
    # -- starting with a capital letter followed by small letters
    firstName = convert_legible_name(firstName)
    lastName = convert_legible_name(lastName)

    if is_already_registered(registeredUsersDB, email):
        raise ValueError(description='Email taken by another user')

    userHandle = generateUserHandle(registeredUsersDB, firstName, lastName)
    password = hashPassword(password)
    u_id = generateU_ID(userHandle)

    permission_id = generate_permission_id(email)
    # Generate a dictionary with the set values
    # and also set some required fields to none if not passed in
    registeredDictionary = generate_empty_user(handle=userHandle,
                                               email=email,
                                               password=password,
                                               u_id=u_id,
                                               first_name=firstName,
                                               last_name=lastName,
                                               permission_id=permission_id)
    registeredUsersDB.append(registeredDictionary)
    # Dictionary of email and password for token generation -- think of it as 'payload'
    userDictionary = generateUserDictionary(email, password)
    token = generateToken(userDictionary)
    # The user registered is now logged in
    loggedInUsersDB.append(registeredDictionary)

    save_registered_users()
    return {'u_id': u_id, 'token': token}
def channel_messages(token, channel_id, start):

    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    start = int(start)
    end = start + PAGINATION()
    channel_id = int(channel_id)
    email = token_to_email(token)

    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description=
            "You must be logged in to view the messages of a channel!")

    u_id = token_to_u_ID(loggedInUsersDB, token)
    channel = getChannel(channelsDB, channel_id)
    messagesLength = len(channel['messagesListDict'])

    if messagesLength < start:
        raise ValueError(description="Starting message too big")

    returnDictionary = {'messages': []}

    if messagesLength < end:
        returnDictionary['end'] = -1
        returnDictionary['start'] = start
    else:
        returnDictionary['end'] = end
        returnDictionary['start'] = start

    for message in channel['messagesListDict']:
        if start == end:
            break
        returnDictionary['messages'].append(message)
        start += 1
    save_channel()
    return returnDictionary
예제 #26
0
def message_edit(token, message_id, editMessage):
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()
    message_id = int(message_id)

    if len(editMessage) > 1000:
        raise ValueError(description="Message too long")

    u_id = token_to_u_ID(loggedInUsersDB, token)
    channel = get_channel(channelsDB, message_id)

    if not is_inChannel(channelsDB=channelsDB,
                        u_id=u_id,
                        channel_id=channel['channel_id']):
        raise AccessError(
            description='You must be in the channel to edit a message!')

    for message in channel['messagesListDict']:
        if message['message_id'] == message_id:
            if message['u_id'] == u_id:
                if editMessage.isspace():
                    message_remove(token, message_id)
                else:
                    message['message'] = editMessage
                return {}
            else:
                for owner in channel['owner_members']:
                    if u_id == owner['u_id']:
                        if editMessage.isspace():
                            message_remove(token, message_id)
                        else:
                            message['message'] = editMessage
                        return {}
                raise AccessError(
                    description=
                    "You did not write this message. You need to be an owner of the channel to edit a message you did not write!"
                )

    raise ValueError(description="Error editting")
예제 #27
0
def user_profile_delete(token, password):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    password = hashPassword(password)
    email = token_to_email(token)
    u_id = token_to_u_ID(registeredUsersDB, token)
    u_id = int(u_id)

    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError("You must be logged in to delete your account")

    delete_user(registeredUsersDB, u_id, password)
    delete_user(loggedInUsersDB, u_id, password)

    for channel in channelsDB:
        remove_user_from_channel(channelsDB, u_id, channel['channel_id'])

    save_channel()
    save_registered_users()
    return {}
def standup_start(token, channel_id, length):
	registeredUsersDB = get_global_registeredUsers()
	loggedInUsersDB = get_global_loggedInUsers()
	channelsDB = get_global_existingChannels()
	
	email = token_to_email(token)
	if not is_loggedIn(loggedInUsersDB, email):
		raise AccessError(description="You should be logged in to start a standup")	
	
	channel_id = int(channel_id)
	channel = getChannel(channelsDB, channel_id)
	u_id = token_to_u_ID(loggedInUsersDB, token)

	if channel['is_standup_running']:
		raise ValueError("Another standup is currently running")
	
	# Only owner of the channel can start a standup
	found = False
	for owner in channel['owner_members']:
		if owner['u_id'] == u_id:
			found = True
	if not found:
		raise AccessError(description='You must be an owner of a channel to start a standup')

	now = datetime.datetime.utcnow()
	time_start = int(now.replace(tzinfo=timezone.utc).timestamp())
	time_end = int(time_start + int(length)) 
	
	tempDict = {}
	tempDict['u_id'] = u_id
	tempDict['isActive'] = True
	tempDict['time_start'] = time_start
	tempDict['time_end'] = time_end
	tempDict['messages'] = ''
	channel['is_standup_running'] = True
	channel['standups'].append(tempDict)

	return {'time_finish': time_end}
def channel_invite(token, channel_id, u_id):
    registeredUsersDB = get_global_registeredUsers()
    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()

    email = token_to_email(token)
    u_id = int(u_id)

    if not is_loggedIn(loggedInUsersDB, email):
        raise AccessError(
            description="You must be logged in invite a friend into a channel!"
        )

    if not is_already_registered(registeredUsersDB, email):
        raise ValueError(description=f"User with ID {u_id} does not exist")

    ownerU_ID = token_to_u_ID(loggedInUsersDB, token)

    ownerU_ID = int(ownerU_ID)
    channel_id = int(channel_id)

    add_to_channel(channelsDB, ownerU_ID, u_id, channel_id)
    save_channel()
    return {}
예제 #30
0
def message_remove(token, message_id):

    loggedInUsersDB = get_global_loggedInUsers()
    channelsDB = get_global_existingChannels()
    message_id = int(message_id)

    u_id = token_to_u_ID(loggedInUsersDB, token)
    channel = get_channel(channelsDB, message_id)
    if not is_inChannel(channelsDB=channelsDB,
                        u_id=u_id,
                        channel_id=channel['channel_id']):
        raise AccessError(
            description='You must be in the channel to remove a message!')

    for message in channel['messagesListDict']:
        if message['message_id'] == message_id:
            if message['u_id'] == u_id:
                channel['messagesListDict'].remove(message)
                return {}
            for owner in channel['owner_members']:
                if u_id == owner['u_id']:
                    channel['messagesListDict'].remove(message)
                    return {}
    raise AccessError(description="You are not allowed to remove this message")