Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/QueueWindowProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IJobContext, IProcessor } from '@rocket.chat/apps-engine/definition/sch
import { Logs } from '../enum/Logs';
import { getError } from './Helper';
import { setIsProcessingMessage } from './Persistence';
import { cancelAllEventSchedulerJobForSessionAndName } from './Scheduler';

export class QueueWindowScheduler implements IProcessor {
public id: string;
Expand All @@ -13,8 +14,11 @@ export class QueueWindowScheduler implements IProcessor {

public async processor(jobContext: IJobContext, read: IRead, modify: IModify, http: IHttp, persistence: IPersistence): Promise<void> {
const sessionId = jobContext.rid;
const eventName = jobContext.eventName;
try {
await setIsProcessingMessage(read, persistence, sessionId, false);
await cancelAllEventSchedulerJobForSessionAndName(modify, sessionId, eventName);
console.log(`{ roomID: ${jobContext.rid} } The DF App is dropping the blackout window from the event ${ eventName } due to blackout`);
} catch (error) {
// Failed to send event, so close blackout window
console.error(`${Logs.DIALOGFLOW_REST_API_ERROR}: { roomID: ${sessionId} } ${getError(error)}`);
Expand Down
4 changes: 4 additions & 0 deletions lib/Scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const cancelAllEventSchedulerJobForSession = async (modify: IModify, sess
await modify.getScheduler().cancelJobByDataQuery({ sessionId, jobName: JobName.EVENT_SCHEDULER });
};

export const cancelAllEventSchedulerJobForSessionAndName = async (modify: IModify, sessionId: string, eventName: string) => {
await modify.getScheduler().cancelJobByDataQuery({ sessionId, jobName: JobName.EVENT_SCHEDULER, eventName });
};

export const cancelAllBlackoutTimeoutSchedulerJobForSession = async (modify: IModify, sessionId: string) => {
await modify.getScheduler().cancelJobByDataQuery({ sessionId, jobName: JobName.CONTINUE_BLACKOUT_TIMEOUT_SCHEDULER });
};
1 change: 1 addition & 0 deletions lib/payloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const handlePayloadActions = async (app: IApp, read: IRead, modify: IMo
rid,
sessionId: rid,
jobName: JobName.CONTINUE_BLACKOUT_TIMEOUT_SCHEDULER,
eventName: params.eventName,
},
};
await cancelAllBlackoutTimeoutSchedulerJobForSession(modify, rid);
Expand Down