diff libervia/frontends/bridge/pb.py @ 4130:02f0adc745c6

core: notifications implementation, first draft: add a new table for notifications, and methods/bridge methods to manipulate them.
author Goffi <goffi@goffi.org>
date Mon, 16 Oct 2023 17:29:31 +0200
parents 26b7ed2817da
children 730f542e4ad0
line wrap: on
line diff
--- a/libervia/frontends/bridge/pb.py	Wed Oct 18 15:30:07 2023 +0200
+++ b/libervia/frontends/bridge/pb.py	Mon Oct 16 17:29:31 2023 +0200
@@ -489,6 +489,42 @@
         else:
             d.addErrback(self._errback, ori_errback=errback)
 
+    def notification_add(self, type_, body_plain, body_rich, title, is_global, requires_action, arg_6, priority, expire_at, extra, callback=None, errback=None):
+        d = self.root.callRemote("notification_add", type_, body_plain, body_rich, title, is_global, requires_action, arg_6, priority, expire_at, extra)
+        if callback is not None:
+            d.addCallback(lambda __: callback())
+        if errback is None:
+            d.addErrback(self._generic_errback)
+        else:
+            d.addErrback(self._errback, ori_errback=errback)
+
+    def notification_delete(self, id_, is_global, profile_key, callback=None, errback=None):
+        d = self.root.callRemote("notification_delete", id_, is_global, profile_key)
+        if callback is not None:
+            d.addCallback(lambda __: callback())
+        if errback is None:
+            d.addErrback(self._generic_errback)
+        else:
+            d.addErrback(self._errback, ori_errback=errback)
+
+    def notifications_expired_clean(self, limit_timestamp, profile_key, callback=None, errback=None):
+        d = self.root.callRemote("notifications_expired_clean", limit_timestamp, profile_key)
+        if callback is not None:
+            d.addCallback(lambda __: callback())
+        if errback is None:
+            d.addErrback(self._generic_errback)
+        else:
+            d.addErrback(self._errback, ori_errback=errback)
+
+    def notifications_get(self, filters, profile_key, callback=None, errback=None):
+        d = self.root.callRemote("notifications_get", filters, profile_key)
+        if callback is not None:
+            d.addCallback(callback)
+        if errback is None:
+            d.addErrback(self._generic_errback)
+        else:
+            d.addErrback(self._errback, ori_errback=errback)
+
     def param_get_a(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
         d = self.root.callRemote("param_get_a", name, category, attribute, profile_key)
         if callback is not None:
@@ -969,6 +1005,26 @@
         d.addErrback(self._errback)
         return d.asFuture(asyncio.get_event_loop())
 
+    def notification_add(self, type_, body_plain, body_rich, title, is_global, requires_action, arg_6, priority, expire_at, extra):
+        d = self.root.callRemote("notification_add", type_, body_plain, body_rich, title, is_global, requires_action, arg_6, priority, expire_at, extra)
+        d.addErrback(self._errback)
+        return d.asFuture(asyncio.get_event_loop())
+
+    def notification_delete(self, id_, is_global, profile_key):
+        d = self.root.callRemote("notification_delete", id_, is_global, profile_key)
+        d.addErrback(self._errback)
+        return d.asFuture(asyncio.get_event_loop())
+
+    def notifications_expired_clean(self, limit_timestamp, profile_key):
+        d = self.root.callRemote("notifications_expired_clean", limit_timestamp, profile_key)
+        d.addErrback(self._errback)
+        return d.asFuture(asyncio.get_event_loop())
+
+    def notifications_get(self, filters, profile_key):
+        d = self.root.callRemote("notifications_get", filters, profile_key)
+        d.addErrback(self._errback)
+        return d.asFuture(asyncio.get_event_loop())
+
     def param_get_a(self, name, category, attribute="value", profile_key="@DEFAULT@"):
         d = self.root.callRemote("param_get_a", name, category, attribute, profile_key)
         d.addErrback(self._errback)