@@ -545,7 +545,8 @@ const getEmailsGroupByThreadByParams = (params = {}) => {
545545 limit,
546546 contactTypes = [ 'from' ] ,
547547 contactFilter,
548- rejectedLabelIds
548+ rejectedLabelIds,
549+ threadIdRejected
549550 } = params ;
550551
551552 let queryDb = baseThreadQuery ( {
@@ -554,13 +555,13 @@ const getEmailsGroupByThreadByParams = (params = {}) => {
554555 limit,
555556 contactTypes,
556557 contactFilter,
557- rejectedLabelIds
558+ rejectedLabelIds,
559+ threadIdRejected
558560 } ) ;
559561
560562 if ( plain ) {
561563 return partThreadQueryByMatchText ( queryDb , text ) ;
562564 }
563-
564565 if ( text ) {
565566 queryDb = queryDb
566567 . andWhere ( 'preview' , 'like' , `%${ text } %` )
@@ -624,7 +625,8 @@ const baseThreadQuery = ({
624625 limit,
625626 contactTypes,
626627 contactFilter,
627- rejectedLabelIds
628+ rejectedLabelIds,
629+ threadIdRejected
628630} ) => {
629631 const {
630632 labelsQuery,
@@ -633,7 +635,7 @@ const baseThreadQuery = ({
633635 whereRawParams
634636 } = getQueryParamsIfOrNotRejectedLabel ( { labelId, rejectedLabelIds } ) ;
635637
636- return db
638+ let query = db
637639 . select (
638640 `${ Table . EMAIL } .*` ,
639641 db . raw ( `IFNULL(${ Table . EMAIL } .threadId ,${ Table . EMAIL } .id) as uniqueId` ) ,
@@ -683,8 +685,12 @@ const baseThreadQuery = ({
683685 `${ Table . EMAIL_CONTACT } .contactId` ,
684686 `${ Table . CONTACT } .id`
685687 )
686- . whereRaw ( whereRawQuery , whereRawParams )
687- . where ( `${ Table . EMAIL } .date` , '<' , date || 'now' )
688+ . whereRaw ( whereRawQuery , whereRawParams ) ;
689+ if ( threadIdRejected !== undefined ) {
690+ query = query . whereNot ( 'uniqueId' , threadIdRejected ) ;
691+ }
692+ return query
693+ . andWhere ( `${ Table . EMAIL } .date` , '<' , date || 'now' )
688694 . groupBy ( 'uniqueId' )
689695 . orderBy ( `${ Table . EMAIL } .date` , 'DESC' )
690696 . limit ( limit || 20 ) ;
0 commit comments