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
3e419e02
Commit
3e419e02
authored
6 years ago
by
Marcos Spessatto Defendi
Committed by
Diego Sampaio
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] Change pagination field to `count` on /chat.search REST endpoint #11340
parent
aee5d309
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/rocketchat-api/server/v1/chat.js
+3
-6
3 additions, 6 deletions
packages/rocketchat-api/server/v1/chat.js
tests/end-to-end/api/05-chat.js
+16
-0
16 additions, 0 deletions
tests/end-to-end/api/05-chat.js
with
19 additions
and
6 deletions
packages/rocketchat-api/server/v1/chat.js
+
3
−
6
View file @
3e419e02
...
...
@@ -123,7 +123,8 @@ RocketChat.API.v1.addRoute('chat.postMessage', { authRequired: true }, {
RocketChat
.
API
.
v1
.
addRoute
(
'
chat.search
'
,
{
authRequired
:
true
},
{
get
()
{
const
{
roomId
,
searchText
,
limit
}
=
this
.
queryParams
;
const
{
roomId
,
searchText
}
=
this
.
queryParams
;
const
{
count
}
=
this
.
getPaginationItems
();
if
(
!
roomId
)
{
throw
new
Meteor
.
Error
(
'
error-roomId-param-not-provided
'
,
'
The required "roomId" query param is missing.
'
);
...
...
@@ -133,12 +134,8 @@ RocketChat.API.v1.addRoute('chat.search', { authRequired: true }, {
throw
new
Meteor
.
Error
(
'
error-searchText-param-not-provided
'
,
'
The required "searchText" query param is missing.
'
);
}
if
(
limit
&&
(
typeof
limit
!==
'
number
'
||
isNaN
(
limit
)
||
limit
<=
0
))
{
throw
new
Meteor
.
Error
(
'
error-limit-param-invalid
'
,
'
The "limit" query parameter must be a valid number and be greater than 0.
'
);
}
let
result
;
Meteor
.
runAsUser
(
this
.
userId
,
()
=>
result
=
Meteor
.
call
(
'
messageSearch
'
,
searchText
,
roomId
,
limi
t
).
message
.
docs
);
Meteor
.
runAsUser
(
this
.
userId
,
()
=>
result
=
Meteor
.
call
(
'
messageSearch
'
,
searchText
,
roomId
,
coun
t
).
message
.
docs
);
return
RocketChat
.
API
.
v1
.
success
({
messages
:
result
...
...
This diff is collapsed.
Click to expand it.
tests/end-to-end/api/05-chat.js
+
16
−
0
View file @
3e419e02
...
...
@@ -362,6 +362,22 @@ describe('[Chat]', function() {
})
.
end
(
done
);
});
it
(
'
should return a list of messages when is provided "count" query parameter execute successfully
'
,
(
done
)
=>
{
request
.
get
(
api
(
'
chat.search
'
))
.
set
(
credentials
)
.
query
({
roomId
:
'
GENERAL
'
,
searchText
:
'
This message was edited via API
'
,
count
:
1
})
.
expect
(
'
Content-Type
'
,
'
application/json
'
)
.
expect
(
200
)
.
expect
((
res
)
=>
{
expect
(
res
.
body
).
to
.
have
.
property
(
'
success
'
,
true
);
expect
(
res
.
body
).
to
.
have
.
property
(
'
messages
'
);
})
.
end
(
done
);
});
});
describe
(
'
[/chat.react]
'
,
()
=>
{
it
(
'
should return statusCode: 200 and success when try unreact a message that
\'
s no reacted yet
'
,
(
done
)
=>
{
...
...
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