Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
RocketChat
Rocket.Chat.js.SDK
Commits
6aa36a8d
Unverified
Commit
6aa36a8d
authored
Jun 12, 2018
by
Mikael Mello
Browse files
Change clientCommand attribute from 'msg' to 'key'
parent
4b64fef8
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
6aa36a8d
...
...
@@ -282,7 +282,7 @@ The `callback` receives a `ClientCommand` object as the first parameter and retu
-
ClientCommand.u._id: ID of the user,
-
ClientCommand.u.username: Username of the user
-
ClientCommand.cmd: Object representing the command itself
-
ClientCommand.
msg: K
ey of the command
-
ClientCommand.
key: String k
ey of the command
-
ClientCommand.options: Addional options or parameters of the command, no defined structure
-
ClientCommand.ts: Timestamp of when the command was issued
...
...
src/config/commandInterfaces.ts
View file @
6aa36a8d
...
...
@@ -8,8 +8,7 @@ export interface IClientCommand {
username
:
string
}
cmd
:
{
msg
:
string
,
options
:
object
key
:
string
}
ts
:
Date
}
...
...
src/lib/driver.ts
View file @
6aa36a8d
...
...
@@ -526,7 +526,7 @@ async function respondToCommands (): Promise<void | void[]> {
if
(
currentReadTime
<=
commandLastReadTime
)
return
// At this point, command has passed checks and can be responded to
logger
.
info
(
`[Command] Received command '
${
command
.
cmd
.
msg
}
' at
${
currentReadTime
}
`
)
logger
.
info
(
`[Command] Received command '
${
command
.
cmd
.
key
}
' at
${
currentReadTime
}
`
)
commandLastReadTime
=
currentReadTime
// Processing completed, call callback to respond to command
...
...
@@ -541,7 +541,7 @@ async function respondToCommands (): Promise<void | void[]> {
* @param command Command object
*/
async
function
commandHandler
(
command
:
IClientCommand
):
Promise
<
void
|
void
[]
>
{
switch
(
command
.
cmd
.
msg
)
{
switch
(
command
.
cmd
.
key
)
{
// SDK-level command to pause the message stream, interrupting all messages from the server
case
'
pauseMessageStream
'
:
subscriptions
.
map
((
s
:
ISubscription
)
=>
(
s
.
_name
===
_messageCollectionName
?
unsubscribe
(
s
)
:
undefined
))
...
...
@@ -562,7 +562,7 @@ async function commandHandler (command: IClientCommand): Promise<void | void[]>
// If command is not at the SDK-level, it tries to call a handler added by the user
default
:
const
handler
=
commandHandlers
[
command
.
cmd
.
msg
]
const
handler
=
commandHandlers
[
command
.
cmd
.
key
]
if
(
handler
)
{
const
result
=
await
handler
(
command
)
await
asyncCall
(
'
replyClientCommand
'
,
[
command
.
_id
,
result
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment