Esempio n. 1
0
def deleteMessage(token, msgId):
    """
    <span class="card-title">>This Call will delete a message by owner token</span>
    <br>
    <b>Route Parameters</b><br>
        - SeToken: token
        - msgId: 1234567890
    <br>
    <br>
    <b>Payload</b><br>
     - NONE
    <br>
    <br>
    <b>Response</b>
    <br>
    200 - JSON Example:<br>
    <code>
        {<br>
            'groupId' : 1234567890,<br>
            'message' : 'hello all',<br>
            'date' : {<br>
                'year': 2015,<br>
                'month': 5,<br>
                'day': 5,<br>
                'hour': 5,<br>
                'minute': 5<br>
            },<br>
            'id' : 1234567890,<br>
            'master_id' : 1234567890,<br>
            'isProject' : false<br>
        }<br>
    </code>
    <br>
    """

    user = get_user_by_token(token)
    if user is None:
        return bad_request("No such User")

    try:
        msg = Message.get_by_id(int(msgId))
    except Exception as e:
        return bad_request("Bad id format")


    if msg is None:
        return bad_request("No such Message")

    if msg.master_id != user.key().id():
        return forbidden("User is not the Creator of the message")

    db.delete(msg)
    db.save
    return no_content()
Esempio n. 2
0
    def show_form_for_new_message(self, thread=None, id=None, friends=None):
        """Shows a form for a brand new message and a reply if given thread and id
        """
        context = {'friends': friends, 'username': self.get_cookie('username')}

        if id and thread:
            id = int(id)
            thread = int(thread)

            msg = Message.get_by_id(id)
            conv = Conversation.get_by_id(thread)

            context['receiver'] = msg.sender
            context['title'] = conv.title

        self.render("messages/new_message.html", context)
Esempio n. 3
0
    def show_form_for_new_message(self, thread=None, id=None, friends=None):
        """Shows a form for a brand new message and a reply if given thread and id
        """
        context = {'friends': friends, 'username': self.get_cookie('username')}

        if id and thread:
            id = int(id)
            thread = int(thread)

            msg = Message.get_by_id(id)
            conv = Conversation.get_by_id(thread)

            context['receiver'] = msg.sender
            context['title'] = conv.title

        self.render("messages/new_message.html", context)
Esempio n. 4
0
    def display_message(self, msg_id, conv_id, friends):
        username = self.get_cookie("username")
        conv = Conversation.get_by_id(conv_id)
        if username not in conv.receivers_list_norm:
            self.abort(403)
        else:
            message = Message.get_by_id(msg_id)
            if message.sender != username:
                message.read = True
            message.put()

            template_values = { 'message' : message,
                                'conv_id': conv_id,
                                'username': username,
                                'friends': friends}

            self.render("messages/display_message.html", template_values)
Esempio n. 5
0
 def display_message(self, msg_id):
     message = Message.get_by_id(msg_id)
     template_values = {'message': message}
     self.render("display_message.html", template_values)
Esempio n. 6
0
 def display_message(self, msg_id):
     message = Message.get_by_id(msg_id)
     template_values = {"message": message}
     self.render("display_message.html", template_values)