Ejemplo n.º 1
0
 def mark_read(self, uuid):
     self._remove(uuid)
     # send update to Channel Group
     self.send_to_groups({
         "type": "notification.dismiss",
         "uuid": JSONEncoder.dumps(uuid)
     })
Ejemplo n.º 2
0
    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())}
        )
Ejemplo n.º 3
0
 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})
Ejemplo n.º 4
0
    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())}
        )
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
 async def async_mark_read(self, uuid):
     self._remove(uuid)
     await self.async_send_to_groups({
         "type": "notification.dismiss",
         "uuid": JSONEncoder.dumps(uuid)
     })