This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Send unread notification counts #456
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
21f135b
Very first cut of calculating actions for events as they come in. Doe…
dbkr a84a693
Having consulted The Erikle, this should go at the end of on_receive_…
dbkr aa667ee
Save event actions to the db
dbkr 5e909c7
Store nothing instead of ['dont_notify'] for events with no notificat…
dbkr 42ad49f
still very WIP, but now sends unread_notifications_count in the room …
dbkr 413d0d6
Make unread notification count sending work: put the correct count in…
dbkr b131fb1
add list of things I want to fix with this branch
dbkr 091c545
pep8
dbkr f73f154
Only run pushers for users on this hs!
dbkr c061b47
Merge remote-tracking branch 'origin/develop' into store_event_actions
dbkr 65c451c
Add bulk push rule evaluator which actually still evaluates rules one…
dbkr 77f0685
clarify problems
dbkr 4c8f6a7
Insert push actions in a single db query rather than one per user/pro…
dbkr 3fbb031
Remove the list of problems (moved to jira issues)
dbkr 5645d97
Add some comments to areas that could be optimised.
dbkr 140a50f
Merge remote-tracking branch 'origin/develop' into store_event_actions
dbkr 9b4cd0c
pep8 & unused variable
dbkr d79e90f
Add mocks to make tests work again
dbkr d2a92c6
Fix merge fail with anon access stuff
dbkr 3051c9d
Address minor PR issues
dbkr 928c575
Merge remote-tracking branch 'origin/develop' into store_event_actions
dbkr c914d67
Rename event-actions to event_push_actions as per PR request
dbkr 92a1e74
fix tests
dbkr f1b6773
Add unread_notif_count in incremental_sync_with_gap
dbkr d74c6ac
comma
dbkr c77e7e6
Only joined rooms have unread_notif_count
dbkr 4eb7b95
= not == in sql
dbkr 85ca8cb
comment typo
dbkr eb03625
Merge remote-tracking branch 'origin/develop' into store_event_actions
dbkr c79f221
Add is_guest flag to users db to track whether a user is a guest user…
dbkr ae1262a
Add schema change file for is_guest flag
dbkr 9929283
Delete notifications for redacted events
dbkr 0e48f7f
fix tests
dbkr b6a5853
Adding is_guest here won't work because it just constructs a dict of …
dbkr 442fcc0
Merge remote-tracking branch 'origin/develop' into store_event_actions
dbkr 09dc985
comma style
dbkr 823b679
more commas
dbkr daadcf3
This comma is actually important
dbkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 OpenMarket Ltd | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from twisted.internet import defer | ||
|
||
import bulk_push_rule_evaluator | ||
|
||
import logging | ||
|
||
from synapse.api.constants import EventTypes | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ActionGenerator: | ||
def __init__(self, store): | ||
self.store = store | ||
# really we want to get all user ids and all profile tags too, | ||
# since we want the actions for each profile tag for every user and | ||
# also actions for a client with no profile tag for each user. | ||
# Currently the event stream doesn't support profile tags on an | ||
# event stream, so we just run the rules for a client with no profile | ||
# tag (ie. we just need all the users). | ||
|
||
@defer.inlineCallbacks | ||
def handle_push_actions_for_event(self, event, handler): | ||
if event.type == EventTypes.Redaction and event.redacts is not None: | ||
yield self.store.remove_push_actions_for_event_id( | ||
event.room_id, event.redacts | ||
) | ||
|
||
bulk_evaluator = yield bulk_push_rule_evaluator.evaluator_for_room_id( | ||
event.room_id, self.store | ||
) | ||
|
||
actions_by_user = yield bulk_evaluator.action_for_event_by_user(event, handler) | ||
|
||
yield self.store.set_push_actions_for_event_and_users( | ||
event, | ||
[ | ||
(uid, None, actions) for uid, actions in actions_by_user.items() | ||
] | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the
hs
and callhs.get_datastore()
to get the store.If you are just using the
store
then just pass that.Try to avoid storing the
hs
on the object if possible to make it clearer what the object uses