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
Container Registry
Model registry
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
Maunium
synapse
Commits
3a00f134
Commit
3a00f134
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Only compute badge count when necessary.
This reverts commit
d7265977
.
parent
c6549117
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
synapse/push/__init__.py
+15
-4
15 additions, 4 deletions
synapse/push/__init__.py
with
15 additions
and
4 deletions
synapse/push/__init__.py
+
15
−
4
View file @
3a00f134
...
@@ -125,9 +125,6 @@ class Pusher(object):
...
@@ -125,9 +125,6 @@ class Pusher(object):
from_tok
=
StreamToken
.
from_string
(
self
.
last_token
)
from_tok
=
StreamToken
.
from_string
(
self
.
last_token
)
config
=
PaginationConfig
(
from_token
=
from_tok
,
limit
=
'
1
'
)
config
=
PaginationConfig
(
from_token
=
from_tok
,
limit
=
'
1
'
)
timeout
=
(
300
+
random
.
randint
(
-
60
,
60
))
*
1000
timeout
=
(
300
+
random
.
randint
(
-
60
,
60
))
*
1000
# note that we need to get read receipts down the stream as we need to
# wake up when one arrives. we don't need to explicitly look for
# them though.
chunk
=
yield
self
.
evStreamHandler
.
get_stream
(
chunk
=
yield
self
.
evStreamHandler
.
get_stream
(
self
.
user_id
,
config
,
timeout
=
timeout
,
affect_presence
=
False
self
.
user_id
,
config
,
timeout
=
timeout
,
affect_presence
=
False
)
)
...
@@ -135,12 +132,23 @@ class Pusher(object):
...
@@ -135,12 +132,23 @@ class Pusher(object):
# limiting to 1 may get 1 event plus 1 presence event, so
# limiting to 1 may get 1 event plus 1 presence event, so
# pick out the actual event
# pick out the actual event
single_event
=
None
single_event
=
None
read_receipt
=
None
for
c
in
chunk
[
'
chunk
'
]:
for
c
in
chunk
[
'
chunk
'
]:
if
'
event_id
'
in
c
:
# Hmmm...
if
'
event_id
'
in
c
:
# Hmmm...
single_event
=
c
single_event
=
c
elif
c
[
'
type
'
]
==
'
m.receipt
'
:
read_receipt
=
c
have_updated_badge
=
False
if
read_receipt
:
for
receipt_part
in
read_receipt
[
'
content
'
].
values
():
if
'
m.read
'
in
receipt_part
:
if
self
.
user_id
in
receipt_part
[
'
m.read
'
].
keys
():
have_updated_badge
=
True
if
not
single_event
:
if
not
single_event
:
yield
self
.
update_badge
()
if
have_updated_badge
:
yield
self
.
update_badge
()
self
.
last_token
=
chunk
[
'
end
'
]
self
.
last_token
=
chunk
[
'
end
'
]
yield
self
.
store
.
update_pusher_last_token
(
yield
self
.
store
.
update_pusher_last_token
(
self
.
app_id
,
self
.
app_id
,
...
@@ -185,6 +193,9 @@ class Pusher(object):
...
@@ -185,6 +193,9 @@ class Pusher(object):
yield
self
.
hs
.
get_pusherpool
().
remove_pusher
(
yield
self
.
hs
.
get_pusherpool
().
remove_pusher
(
self
.
app_id
,
pk
,
self
.
user_id
self
.
app_id
,
pk
,
self
.
user_id
)
)
else
:
if
have_updated_badge
:
yield
self
.
update_badge
()
processed
=
True
processed
=
True
if
not
self
.
alive
:
if
not
self
.
alive
:
...
...
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