File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,6 +178,9 @@ class Audience {
178178 if ( ! project . tk ) {
179179 project . tk = 1 ;
180180 }
181+ if ( ! project . tz ) {
182+ project . tz = 1 ;
183+ }
181184 steps . push ( { $project : project } ) ;
182185 }
183186
@@ -424,7 +427,7 @@ class PlainApiMapper extends Mapper {
424427 map ( user , date , c , offset = 0 ) {
425428 let d = date . getTime ( ) ;
426429 if ( this . trigger . tz ) {
427- let utz = ( user . tz === undefined || user . tz === null ? this . offset || 0 : user . tz || 0 ) * 60000 ;
430+ let utz = ( user . tz === undefined || user . tz === null ? this . offset || 0 : parseFloat ( user . tz ) || 0 ) * 60000 ;
428431 d = date . getTime ( ) - this . trigger . sctz * 60000 - utz ;
429432
430433 if ( d < Date . now ( ) ) {
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const MEDIA_MIME_ANDROID = [
2727
2828const DEFAULTS = {
2929 schedule_ahead : 5 * 60000 , // schedule job needs to be scheduled this much ms prior to the job date
30+ schedule_ahead_tz : 24 * 60 * 60000 , // schedule job needs to be scheduled this much ms prior to the job date if we send in users' timezones
3031 queue_insert_batch : 100000 , // insert into "push" collection in batches of 100 000 records
3132 max_media_size : 1024 * 1024 // 1Mb is a very conservative limit for media attachments
3233} ;
Original file line number Diff line number Diff line change @@ -532,7 +532,7 @@ class Message extends Mongoable {
532532 */
533533 get needsScheduling ( ) {
534534 return this . state === State . Created && this . triggers . filter ( t => t . kind === TriggerKind . Plain &&
535- ( ! t . delayed || ( t . delayed && t . start . getTime ( ) > Date . now ( ) - 5 * 60000 ) ) ) . length > 0 ;
535+ ( ! t . delayed || ( t . delayed && ! t . tz && t . start . getTime ( ) > Date . now ( ) - DEFAULTS . schedule_ahead ) || ( t . delayed && t . tz && t . start . getTime ( ) > Date . now ( ) - DEFAULTS . schedule_ahead_tz ) ) ) . length > 0 ;
536536 }
537537
538538 /**
@@ -659,7 +659,10 @@ class Message extends Mongoable {
659659 }
660660 } ) ;
661661 }
662- let date = plain . delayed ? plain . start . getTime ( ) - DEFAULTS . schedule_ahead : Date . now ( ) ;
662+ let date = Date . now ( ) ;
663+ if ( plain . delayed ) {
664+ date = plain . start . getTime ( ) - ( plain . tz ? DEFAULTS . schedule_ahead_tz : DEFAULTS . schedule_ahead ) ;
665+ }
663666 await require ( '../../../../../api/parts/jobs' ) . job ( 'push:schedule' , { mid : this . _id , aid : this . app } ) . replace ( ) . once ( date ) ;
664667 }
665668 if ( this . triggerAutoOrApi ( ) && ( this . is ( State . Done ) || this . state === State . Created ) ) {
You can’t perform that action at this time.
0 commit comments