Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
5b93937f
Commit
5b93937f
authored
9 years ago
by
Diego Sampaio
Browse files
Options
Downloads
Patches
Plain Diff
using processWebhookMessage on V1 APIs
parent
841656b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/rocketchat-api/server/routes.coffee
+11
-64
11 additions, 64 deletions
packages/rocketchat-api/server/routes.coffee
with
11 additions
and
64 deletions
packages/rocketchat-api/server/routes.coffee
+
11
−
64
View file @
5b93937f
...
...
@@ -54,74 +54,21 @@ RocketChat.API.v1.addRoute 'chat.messageExamples', authRequired: true,
# Send Channel Message
RocketChat
.
API
.
v1
.
addRoute
'chat.postMessage'
,
authRequired
:
true
,
post
:
->
channel
=
@
bodyParams
.
channel
channelType
=
channel
[
0
]
channel
=
channel
.
substr
(
1
)
switch
channelType
when
'#'
room
=
RocketChat
.
models
.
Rooms
.
findOne
$or
:
[
{
_id
:
channel
}
{
name
:
channel
}
]
if
not
room
?
return
RocketChat
.
API
.
v1
.
failure
'invalid-channel'
rid
=
room
.
_id
if
room
.
t
is
'c'
Meteor
.
runAsUser
@
userId
,
->
Meteor
.
call
'joinRoom'
,
room
.
_id
when
'@'
roomUser
=
RocketChat
.
models
.
Users
.
findOne
$or
:
[
{
_id
:
channel
}
{
username
:
channel
}
]
if
not
roomUser
?
return
RocketChat
.
API
.
v1
.
failure
'invalid-channel'
rid
=
[
@
useId
,
roomUser
.
_id
].
sort
().
join
(
''
)
room
=
RocketChat
.
models
.
Rooms
.
findOne
(
rid
)
if
not
room
Meteor
.
runAsUser
@
userId
,
->
Meteor
.
call
'createDirectMessage'
,
roomUser
.
username
room
=
RocketChat
.
models
.
Rooms
.
findOne
(
rid
)
else
return
RocketChat
.
API
.
v1
.
failure
'invalid-channel-type'
message
=
alias
:
@
bodyParams
.
username
or
@
bodyParams
.
alias
msg
:
_
.
trim
(
@
bodyParams
.
text
or
@
bodyParams
.
msg
or
''
)
attachments
:
@
bodyParams
.
attachments
parseUrls
:
false
bot
:
try
@
bodyParams
.
bot
=
u
:
@
userId
groupable
:
false
if
@
bodyParams
.
icon_url
?
or
@
bodyParams
.
avatar
?
message
.
avatar
=
@
bodyParams
.
icon_url
or
@
bodyParams
.
avatar
else
if
@
bodyParams
.
icon_emoji
?
or
@
bodyParams
.
emoji
?
message
.
emoji
=
@
bodyParams
.
icon_emoji
or
@
bodyParams
.
emoji
if
_
.
isArray
message
.
attachments
for
attachment
in
message
.
attachments
if
attachment
.
msg
attachment
.
text
=
_
.
trim
(
attachment
.
msg
)
delete
attachment
.
msg
messageReturn
=
processWebhookMessage
@
bodyParams
,
@
user
message
=
RocketChat
.
sendMessage
@
user
,
message
,
room
,
{}
return
RocketChat
.
API
.
v1
.
success
ts
:
Date
.
now
()
channel
:
channel
message
:
message
if
not
messageReturn
?
return
RocketChat
.
API
.
v1
.
failure
'unknown-error'
return
RocketChat
.
API
.
v1
.
success
ts
:
Date
.
now
()
channel
:
messageReturn
.
channel
message
:
messageReturn
.
message
catch
e
return
RocketChat
.
API
.
v1
.
failure
e
.
error
# Set Channel Topic
RocketChat
.
API
.
v1
.
addRoute
'channels.setTopic'
,
authRequired
:
true
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment