changeset 7441:cf1d1239cd55

model: notification: don't round-trip via list if you want a set 'create' in NotificationModel starts from an empty list, appends entries to it, then converts it to a set. You could equally start with a set and add to it, avoiding the final conversion.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Wed, 28 Nov 2018 21:22:28 +0100
parents f4a9f7a7d030
children 1c68258b14bc
files kallithea/model/notification.py
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/notification.py	Thu Nov 22 22:27:14 2018 +0100
+++ b/kallithea/model/notification.py	Wed Nov 28 21:22:28 2018 +0100
@@ -68,16 +68,15 @@
 
         created_by_obj = User.guess_instance(created_by)
 
-        recipients_objs = []
+        recipients_objs = set()
         if recipients:
             for u in recipients:
                 obj = User.guess_instance(u)
                 if obj is not None:
-                    recipients_objs.append(obj)
+                    recipients_objs.add(obj)
                 else:
                     # TODO: inform user that requested operation couldn't be completed
                     log.error('cannot email unknown user %r', u)
-            recipients_objs = set(recipients_objs)
             log.debug('sending notifications %s to %s',
                 type_, recipients_objs
             )