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
9a090d16
Commit
9a090d16
authored
8 years ago
by
Gabriel Engel
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #5502 from wtsarchive/develop
Add REST API method to list online users in a room
parents
8a531b4e
a43564de
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/rocketchat-api/server/v1/channels.js
+33
-0
33 additions, 0 deletions
packages/rocketchat-api/server/v1/channels.js
packages/rocketchat-api/server/v1/groups.js
+33
-0
33 additions, 0 deletions
packages/rocketchat-api/server/v1/groups.js
with
66 additions
and
0 deletions
packages/rocketchat-api/server/v1/channels.js
+
33
−
0
View file @
9a090d16
...
...
@@ -374,6 +374,39 @@ RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, {
}
});
RocketChat
.
API
.
v1
.
addRoute
(
'
channels.online
'
,
{
authRequired
:
true
},
{
get
:
function
()
{
const
{
query
}
=
this
.
parseJsonQuery
();
const
ourQuery
=
Object
.
assign
({},
query
,
{
t
:
'
c
'
});
const
room
=
RocketChat
.
models
.
Rooms
.
findOne
(
ourQuery
);
if
(
room
==
null
)
{
return
RocketChat
.
API
.
v1
.
failure
(
'
Channel does not exists
'
);
}
const
online
=
RocketChat
.
models
.
Users
.
findUsersNotOffline
({
fields
:
{
username
:
1
}
}).
fetch
();
const
onlineInRoom
=
[];
online
.
forEach
(
user
=>
{
if
(
room
.
usernames
.
indexOf
(
user
.
username
)
!==
-
1
)
{
onlineInRoom
.
push
({
_id
:
user
.
_id
,
username
:
user
.
username
});
}
});
return
RocketChat
.
API
.
v1
.
success
({
online
:
onlineInRoom
});
}
});
RocketChat
.
API
.
v1
.
addRoute
(
'
channels.open
'
,
{
authRequired
:
true
},
{
post
:
function
()
{
const
findResult
=
findChannelById
({
roomId
:
this
.
bodyParams
.
roomId
,
checkedArchived
:
false
});
...
...
This diff is collapsed.
Click to expand it.
packages/rocketchat-api/server/v1/groups.js
+
33
−
0
View file @
9a090d16
...
...
@@ -282,6 +282,39 @@ RocketChat.API.v1.addRoute('groups.list', { authRequired: true }, {
}
});
RocketChat
.
API
.
v1
.
addRoute
(
'
groups.online
'
,
{
authRequired
:
true
},
{
get
:
function
()
{
const
{
query
}
=
this
.
parseJsonQuery
();
const
ourQuery
=
Object
.
assign
({},
query
,
{
t
:
'
p
'
});
const
room
=
RocketChat
.
models
.
Rooms
.
findOne
(
ourQuery
);
if
(
room
==
null
)
{
return
RocketChat
.
API
.
v1
.
failure
(
'
Group does not exists
'
);
}
const
online
=
RocketChat
.
models
.
Users
.
findUsersNotOffline
({
fields
:
{
username
:
1
}
}).
fetch
();
const
onlineInRoom
=
[];
online
.
forEach
(
user
=>
{
if
(
room
.
usernames
.
indexOf
(
user
.
username
)
!==
-
1
)
{
onlineInRoom
.
push
({
_id
:
user
.
_id
,
username
:
user
.
username
});
}
});
return
RocketChat
.
API
.
v1
.
success
({
online
:
onlineInRoom
});
}
});
RocketChat
.
API
.
v1
.
addRoute
(
'
groups.open
'
,
{
authRequired
:
true
},
{
post
:
function
()
{
const
findResult
=
findPrivateGroupByIdOrName
({
roomId
:
this
.
bodyParams
.
roomId
,
userId
:
this
.
userId
,
checkedArchived
:
false
});
...
...
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