def mark_read(self, uuid): self._remove(uuid) # send update to Channel Group self.send_to_groups({ "type": "notification.dismiss", "uuid": JSONEncoder.dumps(uuid) })
async def async_notify(self, message, tags=None, payload=None, uuid=None): note = Notification(message, tags=tags, payload=payload, uuid=uuid) # send notification to Channel Groups await self.async_send_to_groups( {"type": "notification", "notice": JSONEncoder.dumps(note.prepare())} )
def _store(self, notification, *args, **kwargs): # save the notification itself key = self._key_notification(notification.uuid) self._redis.set(key, JSONEncoder.dumps(notification), nx=True) # store the uuid in a sorted set of all user's notifications # scores in sorted set are by time, allowing retreival from specific time periods self._redis.zadd(self._key_user(), {str(notification.uuid): notification.time})
def notify(self, message, tags=None, payload=None, uuid=None): logger.debug( f'Notify: "{message}", tags: {tags}, uuid={uuid}, payload={payload}' ) note = Notification(message, tags=tags, payload=payload, uuid=uuid) # send notification to Channel Groups self.send_to_groups( {"type": "notification", "notice": JSONEncoder.dumps(note.prepare())} )
def test_MetadataType_to_json_works(): # using to_json method makes something that can serialize to JSON md = factory.MetadataTypeFactory.build() result = JSONEncoder.dumps(md.to_json()) assert md.type_name in result
async def async_mark_read(self, uuid): self._remove(uuid) await self.async_send_to_groups({ "type": "notification.dismiss", "uuid": JSONEncoder.dumps(uuid) })