From 7857008183ca681c65e5f15018e2732fe9a9a5bf Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Thu, 6 Dec 2018 17:54:43 +0100 Subject: [PATCH] notifications: use a set initially instead of list later converted to set. --- rhodecode/model/notification.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rhodecode/model/notification.py b/rhodecode/model/notification.py index 97bd67d8..838acf37 100644 --- a/rhodecode/model/notification.py +++ b/rhodecode/model/notification.py @@ -95,15 +95,14 @@ class NotificationModel(BaseModel): log.debug('sending notifications %s to admins: %s', notification_type, recipients_objs) else: - recipients_objs = [] + recipients_objs = set() for u in recipients: obj = self._get_user(u) if obj: - recipients_objs.append(obj) + recipients_objs.add(obj) else: # we didn't find this user, log the error and carry on log.error('cannot notify unknown user %r', u) - recipients_objs = set(recipients_objs) if not recipients_objs: raise Exception('no valid recipients specified') @@ -122,7 +121,7 @@ class NotificationModel(BaseModel): return notification # don't send email to person who created this comment - rec_objs = set(recipients_objs).difference(set([created_by_obj])) + rec_objs = set(recipients_objs).difference({created_by_obj}) # now notify all recipients in question