@@ -398,17 +398,21 @@ def _encodeBody(self, body):
398398 plain_body = MIMEText (body .decode ('ascii' , 'ignore' ))
399399 return plain_body
400400
401- def _targetsByTz (self , notification , signal , targets ):
401+ def _targetsByTz (self , notification , targets ):
402402 """
403403 Take timezone from user property to convert a event time in
404404 notification and also group targets emails by those timezones.
405405 """
406406 tz_targets = {}
407407 targetsCopy = set (targets )
408- for recipient in self ._get_recipients_from_signal (notification , signal ):
409- if recipient .email in targets :
410- tz_targets .setdefault (recipient .timezone , set ()).add (recipient .email )
411- targetsCopy .discard (recipient .email )
408+ for recipient in notification .recipients :
409+ if recipient ['type' ] in ['group' , 'user' ]:
410+ guid = recipient ['value' ]
411+ target_obj = self .guidManager .getObject (guid )
412+ if target_obj :
413+ if target_obj .email in targets and target_obj .timezone :
414+ tz_targets .setdefault (target_obj .timezone , set ()).add (target_obj .email )
415+ targetsCopy .discard (target_obj .email )
412416 if targetsCopy : #some emails are not from users in the system
413417 tz = time .tzname [time .daylight ] # get current timezone factoring in daylight saving
414418 tz_targets .setdefault (tz , set ()).update (targetsCopy )
@@ -425,7 +429,7 @@ def _adjustToTimezone(self, millis, timezone):
425429 def executeBatch (self , notification , signal , targets ):
426430 log .debug ("Executing %s action for targets: %s" , self .name , targets )
427431 self .setupAction (notification .dmd )
428- tz_targets = self ._targetsByTz (notification , signal , targets )
432+ tz_targets = self ._targetsByTz (notification , targets )
429433 original_lst = signal .event .last_seen_time
430434 original_fst = signal .event .first_seen_time
431435 original_sct = signal .event .status_change_time
0 commit comments