mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-19 10:14:18 -05:00
Merge pull request #846 from matrix-org/markjh/user_joined_notifier
Notify users for events in rooms they join.
This commit is contained in:
commit
efe8126290
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from synapse.api.constants import EventTypes
|
from synapse.api.constants import EventTypes, Membership
|
||||||
from synapse.api.errors import AuthError
|
from synapse.api.errors import AuthError
|
||||||
|
|
||||||
from synapse.util.logutils import log_function
|
from synapse.util.logutils import log_function
|
||||||
@ -152,10 +152,6 @@ class Notifier(object):
|
|||||||
self.appservice_handler = hs.get_application_service_handler()
|
self.appservice_handler = hs.get_application_service_handler()
|
||||||
self.state_handler = hs.get_state_handler()
|
self.state_handler = hs.get_state_handler()
|
||||||
|
|
||||||
hs.get_distributor().observe(
|
|
||||||
"user_joined_room", self._user_joined_room
|
|
||||||
)
|
|
||||||
|
|
||||||
self.clock.looping_call(
|
self.clock.looping_call(
|
||||||
self.remove_expired_streams, self.UNUSED_STREAM_EXPIRY_MS
|
self.remove_expired_streams, self.UNUSED_STREAM_EXPIRY_MS
|
||||||
)
|
)
|
||||||
@ -248,6 +244,9 @@ class Notifier(object):
|
|||||||
)
|
)
|
||||||
app_streams |= app_user_streams
|
app_streams |= app_user_streams
|
||||||
|
|
||||||
|
if event.type == EventTypes.Member and event.membership == Membership.JOIN:
|
||||||
|
self._user_joined_room(event.state_key, event.room_id)
|
||||||
|
|
||||||
self.on_new_event(
|
self.on_new_event(
|
||||||
"room_key", room_stream_id,
|
"room_key", room_stream_id,
|
||||||
users=extra_users,
|
users=extra_users,
|
||||||
@ -483,9 +482,8 @@ class Notifier(object):
|
|||||||
user_stream.appservice, set()
|
user_stream.appservice, set()
|
||||||
).add(user_stream)
|
).add(user_stream)
|
||||||
|
|
||||||
def _user_joined_room(self, user, room_id):
|
def _user_joined_room(self, user_id, room_id):
|
||||||
user = str(user)
|
new_user_stream = self.user_to_user_stream.get(user_id)
|
||||||
new_user_stream = self.user_to_user_stream.get(user)
|
|
||||||
if new_user_stream is not None:
|
if new_user_stream is not None:
|
||||||
room_streams = self.room_to_user_streams.setdefault(room_id, set())
|
room_streams = self.room_to_user_streams.setdefault(room_id, set())
|
||||||
room_streams.add(new_user_stream)
|
room_streams.add(new_user_stream)
|
||||||
|
Loading…
Reference in New Issue
Block a user