def notify(self, check) -> None: if not settings.SIGNAL_CLI_ENABLED: raise TransportError("Signal notifications are not enabled") from hc.api.models import TokenBucket if not TokenBucket.authorize_signal(self.channel.phone_number): raise TransportError("Rate limit exceeded") ctx = {"check": check, "down_checks": self.down_checks(check)} text = tmpl("signal_message.html", **ctx) try: dbus.SystemBus().call_blocking( "org.asamk.Signal", "/org/asamk/Signal", "org.asamk.Signal", "sendMessage", "sasas", (text, [], [self.channel.phone_number]), timeout=30, ) except dbus.exceptions.DBusException as e: if "NotFoundException" in str(e): raise TransportError("Recipient not found") raise TransportError("signal-cli call failed")
def notify(self, check): if not settings.SIGNAL_CLI_ENABLED: return "Signal notifications are not enabled" from hc.api.models import TokenBucket if not TokenBucket.authorize_signal(self.channel.phone_number): return "Rate limit exceeded" text = tmpl("signal_message.html", check=check, site_name=settings.SITE_NAME) try: dbus.SystemBus().call_blocking( "org.asamk.Signal", "/org/asamk/Signal", "org.asamk.Signal", "sendMessage", "sasas", (text, [], [self.channel.phone_number]), timeout=30, ) except dbus.exceptions.DBusException as e: if "NotFoundException" in str(e): return "Recipient not found" return "signal-cli call failed"
def notify(self, check, notification=None) -> None: if not settings.SIGNAL_CLI_SOCKET: raise TransportError("Signal notifications are not enabled") from hc.api.models import TokenBucket if not TokenBucket.authorize_signal(self.channel.phone_number): raise TransportError("Rate limit exceeded") ctx = {"check": check, "down_checks": self.down_checks(check)} text = tmpl("signal_message.html", **ctx) self.send(self.channel.phone_number, text)