Hi,

Kallithea has a Notifications feature, where you can get a list of
notifications, like:
'<user> commented on pull request'
'<user> created pull request'
'<user> commented on changeset'
etc.

The page is reachable via the user tab top-right > 'Notifications'.
When you click on a notification, you get some more detail, a
hyperlinked subject (to e.g. the comment or PR in question), and the
body of the notification, e.g. the comment itself.

Personally I have never used this feature for real.
Does anyone actually use it and finds it useful?

Reason why I was looking into this: when creating a notification
(which will also trigger the email sending), a subject is determined,
and that subject is solely used for the aforementioned notification
page. The subject used in emails is completely different.
The 'subject' field of the notifications table in the database is 512
characters long. As this field contains a hyperlink, it could become
quite long if the title of the PR on which a comment is given is very
long. I have observed a psycopg2 database error in such a scenario.

To get rid of the two different subjects, I refactored the code as
below, but then there is no hyperlink to the comment or PR anymore.

diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py
--- a/kallithea/model/notification.py
+++ b/kallithea/model/notification.py
@@ -89,6 +89,9 @@ class NotificationModel(object):
             )
         #else: silently skip notification mails?

+        subject = EmailNotificationModel() \
+                            .get_email_description(type_, **email_kwargs)
+
         # TODO: inform user who are notified
         notif = Notification.create(
             created_by=created_by_obj, subject=subject,
@@ -120,8 +123,6 @@ class NotificationModel(object):

         html_kwargs.update(email_kwargs)
         txt_kwargs.update(email_kwargs)
-        email_subject = EmailNotificationModel() \
-                            .get_email_description(type_, **txt_kwargs)
         email_txt_body = EmailNotificationModel() \
                             .get_email_tmpl(type_, 'txt', **txt_kwargs)
         email_html_body = EmailNotificationModel() \
@@ -132,7 +133,7 @@ class NotificationModel(object):

         # send email with notification to all other participants
         for rec in rec_objs:
-            tasks.send_email([rec.email], email_subject, email_txt_body,
+            tasks.send_email([rec.email], subject, email_txt_body,
                      email_html_body, headers, author=created_by_obj)

         return notif

If however, the entire notifications feature is found not useful by
users, then we can get rid of it entirely.

Thanks,
Thomas
_______________________________________________
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general

Reply via email to