Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Timo Ley
synapse
Commits
776ee6d9
Commit
776ee6d9
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Doc strings
parent
f72ed6c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/presence.py
+28
-0
28 additions, 0 deletions
synapse/handlers/presence.py
with
28 additions
and
0 deletions
synapse/handlers/presence.py
+
28
−
0
View file @
776ee6d9
...
...
@@ -192,6 +192,20 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def
get_state
(
self
,
target_user
,
auth_user
,
as_event
=
False
,
check_auth
=
True
):
"""
Get the current presence state of the given user.
Args:
target_user (UserID): The user whose presence we want
auth_user (UserID): The user requesting the presence, used for
checking if said user is allowed to see the persence of the
`target_user`
as_event (bool): Format the return as an event or not?
check_auth (bool): Perform the auth checks or not?
Returns:
dict: The presence state of the `target_user`, whose format depends
on the `as_event` argument.
"""
if
self
.
hs
.
is_mine
(
target_user
):
if
check_auth
:
visible
=
yield
self
.
is_presence_visible
(
...
...
@@ -234,6 +248,20 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def
get_states
(
self
,
target_users
,
auth_user
,
as_event
=
False
,
check_auth
=
True
):
"""
A batched version of the `get_state` method that accepts a list of
`target_users`
Args:
target_users (list): The list of UserID
'
s whose presence we want
auth_user (UserID): The user requesting the presence, used for
checking if said user is allowed to see the persence of the
`target_users`
as_event (bool): Format the return as an event or not?
check_auth (bool): Perform the auth checks or not?
Returns:
dict: A mapping from user -> presence_state
"""
local_users
,
remote_users
=
partitionbool
(
target_users
,
lambda
u
:
self
.
hs
.
is_mine
(
u
)
...
...
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