mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-24 00:29:28 -05:00
Merge pull request #160 from matrix-org/markjh/appservice_performance
Make the appservice use 'users_in_room' rather than get_room_members …
This commit is contained in:
commit
5d53c14342
@ -148,8 +148,8 @@ class ApplicationService(object):
|
|||||||
and self.is_interested_in_user(event.state_key)):
|
and self.is_interested_in_user(event.state_key)):
|
||||||
return True
|
return True
|
||||||
# check joined member events
|
# check joined member events
|
||||||
for member in member_list:
|
for user_id in member_list:
|
||||||
if self.is_interested_in_user(member.state_key):
|
if self.is_interested_in_user(user_id):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ class ApplicationService(object):
|
|||||||
restrict_to(str): The namespace to restrict regex tests to.
|
restrict_to(str): The namespace to restrict regex tests to.
|
||||||
aliases_for_event(list): A list of all the known room aliases for
|
aliases_for_event(list): A list of all the known room aliases for
|
||||||
this event.
|
this event.
|
||||||
member_list(list): A list of all joined room members in this room.
|
member_list(list): A list of all joined user_ids in this room.
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if this service would like to know about this event.
|
bool: True if this service would like to know about this event.
|
||||||
"""
|
"""
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes
|
||||||
from synapse.appservice import ApplicationService
|
from synapse.appservice import ApplicationService
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
@ -147,10 +147,7 @@ class ApplicationServicesHandler(object):
|
|||||||
)
|
)
|
||||||
# We need to know the members associated with this event.room_id,
|
# We need to know the members associated with this event.room_id,
|
||||||
# if any.
|
# if any.
|
||||||
member_list = yield self.store.get_room_members(
|
member_list = yield self.store.get_users_in_room(event.room_id)
|
||||||
room_id=event.room_id,
|
|
||||||
membership=Membership.JOIN
|
|
||||||
)
|
|
||||||
|
|
||||||
services = yield self.store.get_app_services()
|
services = yield self.store.get_app_services()
|
||||||
interested_list = [
|
interested_list = [
|
||||||
|
@ -217,18 +217,9 @@ class ApplicationServiceTestCase(unittest.TestCase):
|
|||||||
_regex("@irc_.*")
|
_regex("@irc_.*")
|
||||||
)
|
)
|
||||||
join_list = [
|
join_list = [
|
||||||
Mock(
|
"@alice:here",
|
||||||
type="m.room.member", room_id="!foo:bar", sender="@alice:here",
|
"@irc_fo:here", # AS user
|
||||||
state_key="@alice:here"
|
"@bob:here",
|
||||||
),
|
|
||||||
Mock(
|
|
||||||
type="m.room.member", room_id="!foo:bar", sender="@irc_fo:here",
|
|
||||||
state_key="@irc_fo:here" # AS user
|
|
||||||
),
|
|
||||||
Mock(
|
|
||||||
type="m.room.member", room_id="!foo:bar", sender="@bob:here",
|
|
||||||
state_key="@bob:here"
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
self.event.sender = "@xmpp_foobar:matrix.org"
|
self.event.sender = "@xmpp_foobar:matrix.org"
|
||||||
|
Loading…
Reference in New Issue
Block a user