fixed enabled field type for services table
All checks were successful
dreamfall/clacksme/pipeline/head This commit looks good
All checks were successful
dreamfall/clacksme/pipeline/head This commit looks good
This commit is contained in:
parent
57af4f3c8d
commit
8412effa6d
2 changed files with 5 additions and 7 deletions
|
@ -96,19 +96,16 @@ class MailboxNotifier(object):
|
||||||
|
|
||||||
def on_notify(self):
|
def on_notify(self):
|
||||||
self.log.info("Triggering notifications")
|
self.log.info("Triggering notifications")
|
||||||
text = f"New messages have been recieved at {self.mailbox.imap_user}"
|
text = f"New messages have been received at {self.mailbox.imap_user}"
|
||||||
targets = Services.select().where(Services.user == self.mailbox.user)
|
targets = Services.select().where(Services.user == self.mailbox.user)
|
||||||
for target in targets:
|
for target in targets:
|
||||||
|
|
||||||
if target.service == "pushover" and target.enabled:
|
if target.service == "pushover" and target.enabled:
|
||||||
self.send_pushover(target.target, text)
|
self.send_pushover(target.target, text)
|
||||||
|
|
||||||
elif target.service == "mattermost" and target.enabled:
|
if target.service == "mattermost" and target.enabled:
|
||||||
self.send_mattermost(target.target, text)
|
self.send_mattermost(target.target, text)
|
||||||
|
|
||||||
else:
|
|
||||||
self.log.info("unknown notifiaction service")
|
|
||||||
|
|
||||||
def send_pushover(self, po_user, text):
|
def send_pushover(self, po_user, text):
|
||||||
notifier = Notifier.get(Notifier.service == "pushover")
|
notifier = Notifier.get(Notifier.service == "pushover")
|
||||||
url = "https://api.pushover.net/1/messages.json"
|
url = "https://api.pushover.net/1/messages.json"
|
||||||
|
@ -179,7 +176,8 @@ def main():
|
||||||
for mailbox in Mailbox.select():
|
for mailbox in Mailbox.select():
|
||||||
imap_process = MailboxNotifier(mailbox)
|
imap_process = MailboxNotifier(mailbox)
|
||||||
p = Process(
|
p = Process(
|
||||||
target=imap_process.start, name=mailbox.user, args=(log_queue,event_queue,))
|
target=imap_process.start, name=mailbox.user,
|
||||||
|
args=(log_queue,event_queue,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.daemon = True
|
p.daemon = True
|
||||||
p.start()
|
p.start()
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Services(BaseModel):
|
||||||
user = CharField()
|
user = CharField()
|
||||||
service = CharField()
|
service = CharField()
|
||||||
target = CharField()
|
target = CharField()
|
||||||
enabled = CharField(default=True)
|
enabled = BooleanField(default=True)
|
||||||
|
|
||||||
def create_tables():
|
def create_tables():
|
||||||
tables = [System, Mailbox, Events, Notifier, Services]
|
tables = [System, Mailbox, Events, Notifier, Services]
|
||||||
|
|
Loading…
Reference in a new issue