@@ -9,7 +9,7 @@ import { LocaleService } from '@/i18n/ctx'
99import { FlowExtend } from '@/interfaces/flows.interface'
1010import { Paging } from '@/interfaces/paging.interface'
1111import { logger } from '@/utils/logger'
12- import { and , asc , desc , eq , like , ne , sql } from 'drizzle-orm'
12+ import { and , asc , desc , eq , isNotNull , like , ne , sql } from 'drizzle-orm'
1313import { StatusCodes } from 'http-status-codes'
1414import { omit } from 'lodash'
1515import { Inject , Service } from 'typedi'
@@ -265,13 +265,25 @@ export class FlowService {
265265
266266 return result
267267 }
268- public async getFlowByContactId ( contactId : string ) {
268+ public async getFlowByContactId ( contactId : string , isTest : boolean ) {
269269
270- const channel = await this . chanelService . findOneByContactId ( contactId )
270+ const channel = await this . chanelService . findOneByContactId ( contactId ) ;
271+ let flow = null ;
271272
272- const flow = await db . query . flows . findFirst ( {
273- where : eq ( flows . id , channel ?. flowId ) ,
274- } )
273+ if ( isTest ) {
274+ flow = await db . query . flows . findFirst ( {
275+ where : eq ( flows . id , channel ?. flowId ) ,
276+ } ) ;
277+
278+ }
279+ else {
280+ flow = await db . query . flows . findFirst ( {
281+ where : and (
282+ eq ( flows . id , channel ?. flowId ) ,
283+ isNotNull ( flows . publishAt )
284+ ) ,
285+ } ) ;
286+ }
275287
276288 if ( ! flow ) {
277289 throw new HttpException (
0 commit comments