def getUserMessages(self): """ Get the queued messages for the logged in user. @rtype: dictionary @return: B{Properties}: - messages: ([string]) A list of queued messages. """ # user messages are stored in the logged in users "usersettings" object # which must be able to access ZenUsers (off of dmd) messages = IUserMessages(self.context.zport.dmd).get_unread() messages.extend(IBrowserMessages(self.context).get_unread()) messages.sort(key=lambda x:x.timestamp) result = [] for message in messages: result.append(dict( sticky = True if message.priority >= messaging.CRITICAL else False, image = message.image, title = message.title, body = message.body, priority = message.priority )) message.mark_as_read() return { 'messages': result }
def __call__(self): messages = IUserMessages(self.context).get_unread() messages.extend(IBrowserMessages(self.context).get_unread()) messages.sort(key=lambda x: x.timestamp) result = [] for message in messages: result.append( dict(sticky=message.priority >= messaging.CRITICAL and True or False, image=message.image, title=message.title, body=message.body, priority=message.priority)) message.mark_as_read() result = {'totalRecords': len(result), 'messages': result} return result