Skip to content

Commit

Permalink
Merge branch 'release-6.5.0' into regression/start-queue-on-invalidat…
Browse files Browse the repository at this point in the history
…ed-license
  • Loading branch information
kodiakhq[bot] authored Nov 17, 2023
2 parents f2be62b + 4a0251c commit 2fb1d90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apps/meteor/server/models/raw/LivechatInquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export class LivechatInquiryRaw extends BaseRaw<ILivechatInquiryRecord> implemen
}

async unlock(inquiryId: string): Promise<UpdateResult> {
return this.updateOne({ _id: inquiryId }, { $unset: { locked: 1, lockedAt: 1 } });
}

async unlockAndQueue(inquiryId: string): Promise<UpdateResult> {
return this.updateOne(
{ _id: inquiryId },
{ $unset: { locked: 1, lockedAt: 1 }, $set: { status: LivechatInquiryStatus.QUEUED, queuedAt: new Date() } },
Expand Down Expand Up @@ -283,7 +287,7 @@ export class LivechatInquiryRaw extends BaseRaw<ILivechatInquiryRecord> implemen
},
{
$set: { status: LivechatInquiryStatus.TAKEN, takenAt: new Date() },
$unset: { defaultAgent: 1, estimatedInactivityCloseTimeAt: 1 },
$unset: { defaultAgent: 1, estimatedInactivityCloseTimeAt: 1, queuedAt: 1 },
},
);
}
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/server/services/omnichannel/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ export class OmnichannelQueue implements IOmnichannelQueue {
// Note: this removes the "one-shot" behavior of queue, allowing it to take a conversation again in the future
// And sorting them by _updatedAt: -1 will make it so that the oldest inquiries are taken first
// preventing us from playing with the same inquiry over and over again
await LivechatInquiry.unlock(nextInquiry._id);
return await LivechatInquiry.unlockAndQueue(nextInquiry._id);
}

await LivechatInquiry.unlock(nextInquiry._id);
} catch (e) {
queueLogger.error({
msg: 'Error processing queue',
Expand Down
1 change: 1 addition & 0 deletions packages/model-typings/src/models/ILivechatInquiryModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ILivechatInquiryModel extends IBaseModel<ILivechatInquiryRecord
setLastMessageByRoomId(rid: string, message: IMessage): Promise<UpdateResult>;
findNextAndLock(queueSortBy: OmnichannelSortingMechanismSettingType, department?: string): Promise<ILivechatInquiryRecord | null>;
unlock(inquiryId: string): Promise<UpdateResult>;
unlockAndQueue(inquiryId: string): Promise<UpdateResult>;
unlockAll(): Promise<UpdateResult | Document>;
getCurrentSortedQueueAsync(props: {
inquiryId?: string;
Expand Down

0 comments on commit 2fb1d90

Please sign in to comment.