def clean_chat_from_non_users(self): import logging for email in self.participants: try: User.all().filter('address =', email).fetch(1)[0] except IndexError: logging.error("Cleaning away non user %s from chat %s" % (email, self.title)) self.remove_participant(email)
def add_participant(self, address): """ Adds a user to a chat and also sends an invitation to the user to authorize the channel. """ if address in [u.address for u in User.all()]: db.run_in_transaction(self._add_participantTx, address) xmpp.send_invite(address, self.jid)
def get(self, _key_or_title): chat = self._get_chat(_key_or_title) if chat != None: chat.clean_chat_from_non_users() template_values = { 'chat': chat, 'users': User.all() } self.Render("chat.html", template_values)
def non_users(self): return [ u for u in User.all() if not self.title in [c.title for c in u.chats] ]
def remove_listener(self, address): if address not in self.non_listeners and address in [ u.address for u in User.all() ]: self.non_listeners.append(address) self.put()
def get(self): template_values = { 'users': User.all(), } self.Render("users.html", template_values)
def remove_listener(self, address): if address not in self.non_listeners and address in [u.address for u in User.all()]: self.non_listeners.append(address) self.put()
def non_users(self): return [u for u in User.all() if not self.title in [c.title for c in u.chats]]