[FIX] Message preview not available for queued chats (#25092)
Co-authored-by: Kevin Aleman <kaleman960@gmail.com>pull/25272/head
parent
774f52671b
commit
65e54c2b52
@ -0,0 +1,35 @@ |
||||
import { isOmnichannelRoom, isEditedMessage } from '@rocket.chat/core-typings'; |
||||
|
||||
import { callbacks } from '../../../../lib/callbacks'; |
||||
import { LivechatInquiry } from '../../../models/server/raw'; |
||||
import { settings } from '../../../settings/server'; |
||||
import { RoutingManager } from '../lib/RoutingManager'; |
||||
|
||||
callbacks.add( |
||||
'afterSaveMessage', |
||||
async (message, room) => { |
||||
if (!isOmnichannelRoom(room)) { |
||||
return message; |
||||
} |
||||
|
||||
// skip callback if message was edited
|
||||
if (isEditedMessage(message)) { |
||||
return message; |
||||
} |
||||
|
||||
if (!RoutingManager.getConfig().showQueue) { |
||||
// since last message is only getting used on UI as preview message when queue is enabled
|
||||
return message; |
||||
} |
||||
|
||||
if (!settings.get('Store_Last_Message')) { |
||||
return message; |
||||
} |
||||
|
||||
await LivechatInquiry.setLastMessageByRoomId(room._id, message); |
||||
|
||||
return message; |
||||
}, |
||||
callbacks.priority.LOW, |
||||
'save-last-message-to-inquiry', |
||||
); |
||||
@ -1,35 +1,37 @@ |
||||
import type { IRocketChatRecord } from "./IRocketChatRecord"; |
||||
import type { IMessage } from './IMessage'; |
||||
import type { IRocketChatRecord } from './IRocketChatRecord'; |
||||
|
||||
export interface IInquiry { |
||||
_id: string; |
||||
_updatedAt?: Date; |
||||
department?: string; |
||||
_id: string; |
||||
_updatedAt?: Date; |
||||
department?: string; |
||||
} |
||||
|
||||
export enum LivechatInquiryStatus { |
||||
QUEUED = "queued", |
||||
TAKEN = "taken", |
||||
READY = "ready", |
||||
QUEUED = 'queued', |
||||
TAKEN = 'taken', |
||||
READY = 'ready', |
||||
} |
||||
|
||||
export interface IVisitor { |
||||
_id: string; |
||||
username: string; |
||||
token: string; |
||||
status: string; |
||||
_id: string; |
||||
username: string; |
||||
token: string; |
||||
status: string; |
||||
} |
||||
|
||||
export interface ILivechatInquiryRecord extends IRocketChatRecord { |
||||
rid: string; |
||||
name: string; |
||||
ts: Date; |
||||
message: string; |
||||
status: LivechatInquiryStatus; |
||||
v: IVisitor; |
||||
t: "l"; |
||||
queueOrder: number; |
||||
estimatedWaitingTimeQueue: number; |
||||
estimatedServiceTimeAt: string; |
||||
department: string; |
||||
estimatedInactivityCloseTimeAt: Date; |
||||
rid: string; |
||||
name: string; |
||||
ts: Date; |
||||
message: string; |
||||
status: LivechatInquiryStatus; |
||||
v: IVisitor; |
||||
t: 'l'; |
||||
queueOrder: number; |
||||
estimatedWaitingTimeQueue: number; |
||||
estimatedServiceTimeAt: string; |
||||
department: string; |
||||
estimatedInactivityCloseTimeAt: Date; |
||||
lastMessage?: IMessage & { token?: string }; |
||||
} |
||||
|
||||
Loading…
Reference in new issue