From 68b7a5e922472202599ae598cc490865ef20bbb0 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 11 Jun 2018 23:38:03 +0100 Subject: Add thread watchers --- app/views/threads.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'app/views') diff --git a/app/views/threads.py b/app/views/threads.py index c975e5f..a842d58 100644 --- a/app/views/threads.py +++ b/app/views/threads.py @@ -48,6 +48,20 @@ def thread_page(id): db.session.add(reply) thread.replies.append(reply) + if not current_user in thread.watchers: + thread.watchers.append(current_user) + + msg = None + if thread.package is None: + msg = "New comment on '{}'".format(thread.title) + else: + msg = "New comment on '{}' on package {}".format(thread.title, thread.package.title) + + + for user in thread.watchers: + if user != current_user: + triggerNotif(user, current_user, msg, url_for("thread_page", id=thread.id)) + db.session.commit() return redirect(url_for("thread_page", id=id)) @@ -111,6 +125,10 @@ def new_thread_page(): thread.package = package db.session.add(thread) + thread.watchers.append(current_user) + if package is not None and package.author != current_user: + thread.watchers.append(package.author) + reply = ThreadReply() reply.thread = thread reply.author = current_user @@ -127,7 +145,6 @@ def new_thread_page(): if package is not None: triggerNotif(package.author, current_user, "New thread '{}' on package {}".format(thread.title, package.title), url_for("thread_page", id=thread.id)) - db.session.commit() db.session.commit() -- cgit v1.2.3