Skip to content

Commit

Permalink
Chore: More Omnichannel tests (#26691)
Browse files Browse the repository at this point in the history
Co-authored-by: Cauê Felchar <[email protected]>
  • Loading branch information
KevLehman and cauefcr authored Aug 26, 2022
1 parent 74ea125 commit 4344746
Show file tree
Hide file tree
Showing 8 changed files with 724 additions and 203 deletions.
3 changes: 3 additions & 0 deletions apps/meteor/app/lib/server/functions/loadMessageHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export function loadMessageHistory({
limit = 20,
ls,
showThreadMessages = true,
offset = 0,
}: {
userId: string;
rid: string;
end: string;
limit: number;
ls: string;
showThreadMessages: boolean;
offset: number;
}) {
const room = Rooms.findOneById(rid, { fields: { sysMes: 1 } });

Expand All @@ -28,6 +30,7 @@ export function loadMessageHistory({
ts: -1,
},
limit,
skip: offset,
fields: {},
};

Expand Down
52 changes: 24 additions & 28 deletions apps/meteor/app/livechat/server/api/v1/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,30 @@ const cachedSettings = mem(settings, { maxAge: 1000, cacheKey: JSON.stringify })

API.v1.addRoute('livechat/config', {
async get() {
try {
check(this.queryParams, {
token: Match.Maybe(String),
department: Match.Maybe(String),
businessUnit: Match.Maybe(String),
});
const enabled = Livechat.enabled();

if (!enabled) {
return API.v1.success({ config: { enabled: false } });
}

const { token, department, businessUnit } = this.queryParams;

const config = await cachedSettings({ businessUnit });

const status = Livechat.online(department);
const guest = token && (await Livechat.findGuest(token));

const room = guest && findOpenRoom(token);
const agent = guest && room && room.servedBy && findAgent(room.servedBy._id);

const extra = await getExtraConfigInfo(room);
return API.v1.success({
config: { ...config, online: status, guest, room, agent, ...extra },
});
} catch (e) {
return API.v1.failure(e);
check(this.queryParams, {
token: Match.Maybe(String),
department: Match.Maybe(String),
businessUnit: Match.Maybe(String),
});
const enabled = Livechat.enabled();

if (!enabled) {
return API.v1.success({ config: { enabled: false } });
}

const { token, department, businessUnit } = this.queryParams;

const config = await cachedSettings({ businessUnit });

const status = Livechat.online(department);
const guest = token && (await Livechat.findGuest(token));

const room = guest && findOpenRoom(token);
const agent = guest && room && room.servedBy && findAgent(room.servedBy._id);

const extra = await getExtraConfigInfo(room);
return API.v1.success({
config: { ...config, online: status, guest, room, agent, ...extra },
});
},
});
Loading

0 comments on commit 4344746

Please sign in to comment.