Ejemplo n.º 1
0
    def change_schedule(self, email, password, post_id, new_message_text, post_datetime):
        # confirm if email is in database
        try:
            customers_collection.find_one({"email": email})
        except:
            return "Email does not exist", 402
        # confirm email-password match
        entry = Entry()
        correct_password = entry.verify_password(email, password)
        if not correct_password:
            return "Incorrect password", 405

        # verify if user has access to the post
        correct_email = entry.verify_email_to_post(post_id, email)
        if not correct_email:
            return "Unauthorized request", 403

        # find the post to be deleted
        post_to_change = publishing_collection.find_one({"_id": post_id})

        # delete the scheduled post
        publishing_collection.update_one({
        "_id": post_id
        }, {
        "$set": {
        "body": new_message_text,
        "post_datetime": post_datetime
        }
        })

        return "Post updated", 200
Ejemplo n.º 2
0
    def kill_scheduled_post(self, email, password, post_id):
        # confirm if email is in database
        try:
            customers_collection.find_one({"email": email})
        except:
            return "Email does not exist", 402
        # confirm email-password match
        entry = Entry()
        correct_password = entry.verify_password(email, password)
        if not correct_password:
            return "Incorrect password", 405

        # verify if user has access to the post
        correct_email = entry.verify_email_to_post(post_id, email)
        if not correct_email:
            return "Unauthorized request", 403

        # find the post to be deleted
        post_to_delete = publishing_collection.find_one({"_id": post_id})

        # delete the scheduled post
        publishing_collection.delete_one(post_to_delete)

        return "Post deleted", 200