New setting general.reply-notifications

master
Pelle Nilsson 6 years ago
parent 171fcfab72
commit 1dd95d5aad

@ -96,13 +96,16 @@ class Isso(object):
super(Isso, self).__init__(conf)
subscribers = []
smtp_backend = False
for backend in conf.getlist("general", "notify"):
if backend == "stdout":
subscribers.append(Stdout(None))
elif backend in ("smtp", "SMTP"):
subscribers.append(SMTP(self))
smtp_backend = True
else:
logger.warn("unknown notification backend '%s'", backend)
if smtp_backend or conf.getboolean("general", "reply-notifications"):
subscribers.append(SMTP(self))
self.signal = ext.Signal(*subscribers)

@ -76,6 +76,8 @@ class SMTP(object):
self.isso = isso
self.conf = isso.conf.section("smtp")
self.public_endpoint = isso.conf.get("server", "public-endpoint") or local("host")
self.admin_notify = any((n in ("smtp", "SMTP")) for n in isso.conf.getlist("general", "notify"))
self.reply_notify = isso.conf.getboolean("general", "reply-notifications")
# test SMTP connectivity
try:
@ -143,8 +145,9 @@ class SMTP(object):
return rv.read()
def notify_new(self, thread, comment):
body = self.format(thread, comment, None, admin=True)
self.sendmail(thread["title"], body, thread, comment)
if self.admin_notify:
body = self.format(thread, comment, None, admin=True)
self.sendmail(thread["title"], body, thread, comment)
if comment["mode"] == 1:
self.notify_users(thread, comment)
@ -153,7 +156,7 @@ class SMTP(object):
self.notify_users(thread, comment)
def notify_users(self, thread, comment):
if "parent" in comment and comment["parent"] is not None:
if self.reply_notify and "parent" in comment and comment["parent"] is not None:
# Notify interested authors that a new comment is posted
notified = []
parent_comment = self.isso.db.comments.get(comment["parent"])
@ -226,5 +229,5 @@ class Stdout(object):
def _delete_comment(self, id):
logger.info('comment %i deleted', id)
def _activate_comment(self, id):
logger.info("comment %s activated" % id)
def _activate_comment(self, thread, comment):
logger.info("comment %(id)s activated" % thread)

@ -9,6 +9,7 @@ dbpath = /var/isso/comments.db
host = http://isso-dev.local/
max-age = 15m
notify = stdout
reply-notifications = false
log-file = /var/log/isso.log
admin_password = strong_default_password_for_isso_admin

@ -43,6 +43,11 @@ max-age = 15m
# moderated) and deletion links.
notify = stdout
# Allow users to request E-mail notifications for replies to their post.
# WARNING: It is highly recommended to also turn on moderation when enabling
# this setting, as Isso can otherwise be easily exploited for sending spam.
reply-notifications=false
# Log console messages to file instead of standard output.
log-file =

Loading…
Cancel
Save