Exemple #1
0
 def notify_user(self, sender, conv_id, msg):
     #TODO: use boilerplate/task queue
     conv = Conversation.get_by_id(int(conv_id))
     for uname in conv.receivers_list_norm:
         if uname != sender:
             user = User.get_user(uname)
             if user.notify_on_msg:
                 new_message_notify(user.email, conv_id, msg)
Exemple #2
0
    def display_message(self, msg_id, conv_id):
        conv = Conversation.get_by_id(conv_id)
        if self.username not in conv.receivers_list_norm:
            self.abort(403)
        else:
            message = Message.get_by_id(msg_id)
            if message.sender != self.username:
                message.read = True
                message.put()

            template_values = { 'message' : message,
                                'conv_id': conv_id,
                                'username': self.username,}

            self.render_template("messages/display_message.html", **template_values)
Exemple #3
0
    def show_form_for_new_message(self, thread=None, id=None):
        """Shows a form for a brand new message and a reply if given thread and id
        """
        context = {'username': self.username}

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

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

            self.form.receiver.data = msg.sender
            self.form.title.data = conv.title

        self.render_template("messages/new_message.html", **context)