-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
48 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
import { findRoom, findGuest, settings, online } from '../lib/livechat'; | ||
import livechat from '../lib/livechat'; | ||
|
||
RocketChat.API.v1.addRoute('livechat/config', { | ||
get() { | ||
try { | ||
check(this.queryParams, { | ||
token: Match.Maybe(String), | ||
}); | ||
|
||
const config = settings(); | ||
if (!config.enabled) { | ||
return RocketChat.API.v1.success({ config: { enabled: false } }); | ||
} | ||
const config = livechat.settings; | ||
if (!config.enabled) { | ||
return RocketChat.API.v1.success({ config: { enabled: false } }); | ||
} | ||
|
||
const { status } = online(); | ||
const { online } = livechat; | ||
Object.assign(config, { online }); | ||
return RocketChat.API.v1.success({ config }); | ||
}, | ||
}); | ||
|
||
let guest; | ||
let room; | ||
let agent; | ||
RocketChat.API.v1.addRoute('livechat/config/:token', { | ||
get() { | ||
const config = livechat.settings; | ||
if (!config.enabled) { | ||
return RocketChat.API.v1.success({ config: { enabled: false } }); | ||
} | ||
|
||
if (this.queryParams.token) { | ||
guest = findGuest(this.queryParams.token); | ||
room = findRoom(this.queryParams.token); | ||
agent = room && room.servedBy && RocketChat.models.Users.getAgentInfo(room.servedBy._id); | ||
} | ||
const { online } = livechat; | ||
const guest = livechat.findGuest(this.urlParams.token); | ||
const room = livechat.findRoom(this.urlParams.token); | ||
const agent = room && room.servedBy && RocketChat.models.Users.getAgentInfo(room.servedBy._id); | ||
|
||
Object.assign(config, { online: status, guest, room, agent }); | ||
Object.assign(config, { online, guest, room, agent }); | ||
|
||
return RocketChat.API.v1.success({ config }); | ||
} catch (e) { | ||
return RocketChat.API.v1.failure(e); | ||
} | ||
return RocketChat.API.v1.success({ config }); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters