def notify_user(self, sender, conv_id, msg): #TODO: use 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)
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)
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)