diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 3b37e49e6f..b95c4b8bf7 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -40,7 +40,7 @@ class DirectoryHandler(BaseHandler):
# TODO(erikj): Do auth.
- if not room_alias.is_mine:
+ if not self.hs.is_mine(room_alias):
raise SynapseError(400, "Room alias must be local")
# TODO(erikj): Change this.
@@ -64,7 +64,7 @@ class DirectoryHandler(BaseHandler):
def delete_association(self, user_id, room_alias):
# TODO Check if server admin
- if not room_alias.is_mine:
+ if not self.hs.is_mine(room_alias):
raise SynapseError(400, "Room alias must be local")
room_id = yield self.store.delete_room_alias(room_alias)
@@ -75,7 +75,7 @@ class DirectoryHandler(BaseHandler):
@defer.inlineCallbacks
def get_association(self, room_alias):
room_id = None
- if room_alias.is_mine:
+ if self.hs.is_mine(room_alias):
result = yield self.store.get_association_from_room_alias(
room_alias
)
@@ -123,7 +123,7 @@ class DirectoryHandler(BaseHandler):
@defer.inlineCallbacks
def on_directory_query(self, args):
room_alias = self.hs.parse_roomalias(args["room_alias"])
- if not room_alias.is_mine:
+ if not self.hs.is_mine(room_alias):
raise SynapseError(
400, "Room Alias is not hosted on this Home Server"
)
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 42dc4d46f3..269d6622e1 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -79,7 +79,7 @@ class MessageHandler(BaseHandler):
self.ratelimit(event.user_id)
# TODO(paul): Why does 'event' not have a 'user' object?
user = self.hs.parse_userid(event.user_id)
- assert user.is_mine, "User must be our own: %s" % (user,)
+ assert self.hs.is_mine(user), "User must be our own: %s" % (user,)
snapshot = yield self.store.snapshot_room(event)
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index b55d589daf..179b431aa5 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -147,7 +147,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def is_presence_visible(self, observer_user, observed_user):
- assert(observed_user.is_mine)
+ assert(self.hs.is_mine(observed_user))
if observer_user == observed_user:
defer.returnValue(True)
@@ -165,7 +165,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def get_state(self, target_user, auth_user, as_event=False):
- if target_user.is_mine:
+ if self.hs.is_mine(target_user):
visible = yield self.is_presence_visible(
observer_user=auth_user,
observed_user=target_user
@@ -212,7 +212,7 @@ class PresenceHandler(BaseHandler):
# TODO (erikj): Turn this back on. Why did we end up sending EDUs
# everywhere?
- if not target_user.is_mine:
+ if not self.hs.is_mine(target_user):
raise SynapseError(400, "User is not hosted on this Home Server")
if target_user != auth_user:
@@ -291,7 +291,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def user_joined_room(self, user, room_id):
- if user.is_mine:
+ if self.hs.is_mine(user):
statuscache = self._get_or_make_usercache(user)
# No actual update but we need to bump the serial anyway for the
@@ -309,7 +309,7 @@ class PresenceHandler(BaseHandler):
rm_handler = self.homeserver.get_handlers().room_member_handler
curr_users = yield rm_handler.get_room_members(room_id)
- for local_user in [c for c in curr_users if c.is_mine]:
+ for local_user in [c for c in curr_users if self.hs.is_mine(c)]:
self.push_update_to_local_and_remote(
observed_user=local_user,
users_to_push=[user],
@@ -318,14 +318,14 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def send_invite(self, observer_user, observed_user):
- if not observer_user.is_mine:
+ if not self.hs.is_mine(observer_user):
raise SynapseError(400, "User is not hosted on this Home Server")
yield self.store.add_presence_list_pending(
observer_user.localpart, observed_user.to_string()
)
- if observed_user.is_mine:
+ if self.hs.is_mine(observed_user):
yield self.invite_presence(observed_user, observer_user)
else:
yield self.federation.send_edu(
@@ -339,7 +339,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def _should_accept_invite(self, observed_user, observer_user):
- if not observed_user.is_mine:
+ if not self.hs.is_mine(observed_user):
defer.returnValue(False)
row = yield self.store.has_presence_state(observed_user.localpart)
@@ -359,7 +359,7 @@ class PresenceHandler(BaseHandler):
observed_user.localpart, observer_user.to_string()
)
- if observer_user.is_mine:
+ if self.hs.is_mine(observer_user):
if accept:
yield self.accept_presence(observed_user, observer_user)
else:
@@ -396,7 +396,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def drop(self, observed_user, observer_user):
- if not observer_user.is_mine:
+ if not self.hs.is_mine(observer_user):
raise SynapseError(400, "User is not hosted on this Home Server")
yield self.store.del_presence_list(
@@ -410,7 +410,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
def get_presence_list(self, observer_user, accepted=None):
- if not observer_user.is_mine:
+ if not self.hs.is_mine(observer_user):
raise SynapseError(400, "User is not hosted on this Home Server")
presence = yield self.store.get_presence_list(
@@ -465,7 +465,7 @@ class PresenceHandler(BaseHandler):
)
for target_user in target_users:
- if target_user.is_mine:
+ if self.hs.is_mine(target_user):
self._start_polling_local(user, target_user)
# We want to tell the person that just came online
@@ -477,7 +477,7 @@ class PresenceHandler(BaseHandler):
)
deferreds = []
- remote_users = [u for u in target_users if not u.is_mine]
+ remote_users = [u for u in target_users if not self.hs.is_mine(u)]
remoteusers_by_domain = partition(remote_users, lambda u: u.domain)
# Only poll for people in our get_presence_list
for domain in remoteusers_by_domain:
@@ -520,7 +520,7 @@ class PresenceHandler(BaseHandler):
def stop_polling_presence(self, user, target_user=None):
logger.debug("Stop polling for presence from %s", user)
- if not target_user or target_user.is_mine:
+ if not target_user or self.hs.is_mine(target_user):
self._stop_polling_local(user, target_user=target_user)
deferreds = []
@@ -579,7 +579,7 @@ class PresenceHandler(BaseHandler):
@defer.inlineCallbacks
@log_function
def push_presence(self, user, statuscache):
- assert(user.is_mine)
+ assert(self.hs.is_mine(user))
logger.debug("Pushing presence update from %s", user)
@@ -691,7 +691,7 @@ class PresenceHandler(BaseHandler):
for poll in content.get("poll", []):
user = self.hs.parse_userid(poll)
- if not user.is_mine:
+ if not self.hs.is_mine(user):
continue
# TODO(paul) permissions checks
@@ -706,7 +706,7 @@ class PresenceHandler(BaseHandler):
for unpoll in content.get("unpoll", []):
user = self.hs.parse_userid(unpoll)
- if not user.is_mine:
+ if not self.hs.is_mine(user):
continue
if user in self._remote_sendmap:
@@ -725,7 +725,7 @@ class PresenceHandler(BaseHandler):
localusers, remoteusers = partitionbool(
users_to_push,
- lambda u: u.is_mine
+ lambda u: self.hs.is_mine(u)
)
localusers = set(localusers)
@@ -783,7 +783,7 @@ class PresenceEventSource(object):
[u.to_string() for u in observer_user, observed_user])):
defer.returnValue(True)
- if observed_user.is_mine:
+ if self.hs.is_mine(observed_user):
pushmap = presence._local_pushmap
defer.returnValue(
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index 814b3b68fe..0116ba5358 100644
--- a/synapse/handlers/profile.py
+++ b/synapse/handlers/profile.py
@@ -51,7 +51,7 @@ class ProfileHandler(BaseHandler):
@defer.inlineCallbacks
def get_displayname(self, target_user):
- if target_user.is_mine:
+ if self.hs.is_mine(target_user):
displayname = yield self.store.get_profile_displayname(
target_user.localpart
)
@@ -81,7 +81,7 @@ class ProfileHandler(BaseHandler):
def set_displayname(self, target_user, auth_user, new_displayname):
"""target_user is the user whose displayname is to be changed;
auth_user is the user attempting to make this change."""
- if not target_user.is_mine:
+ if not self.hs.is_mine(target_user):
raise SynapseError(400, "User is not hosted on this Home Server")
if target_user != auth_user:
@@ -101,7 +101,7 @@ class ProfileHandler(BaseHandler):
@defer.inlineCallbacks
def get_avatar_url(self, target_user):
- if target_user.is_mine:
+ if self.hs.is_mine(target_user):
avatar_url = yield self.store.get_profile_avatar_url(
target_user.localpart
)
@@ -130,7 +130,7 @@ class ProfileHandler(BaseHandler):
def set_avatar_url(self, target_user, auth_user, new_avatar_url):
"""target_user is the user whose avatar_url is to be changed;
auth_user is the user attempting to make this change."""
- if not target_user.is_mine:
+ if not self.hs.is_mine(target_user):
raise SynapseError(400, "User is not hosted on this Home Server")
if target_user != auth_user:
@@ -150,7 +150,7 @@ class ProfileHandler(BaseHandler):
@defer.inlineCallbacks
def collect_presencelike_data(self, user, state):
- if not user.is_mine:
+ if not self.hs.is_mine(user):
defer.returnValue(None)
with PreserveLoggingContext():
@@ -170,7 +170,7 @@ class ProfileHandler(BaseHandler):
@defer.inlineCallbacks
def on_profile_query(self, args):
user = self.hs.parse_userid(args["user_id"])
- if not user.is_mine:
+ if not self.hs.is_mine(user):
raise SynapseError(400, "User is not hosted on this Home Server")
just_field = args.get("field", None)
@@ -191,7 +191,7 @@ class ProfileHandler(BaseHandler):
@defer.inlineCallbacks
def _update_join_states(self, user):
- if not user.is_mine:
+ if not self.hs.is_mine(user):
return
joins = yield self.store.get_rooms_for_user_where_membership_is(
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 88955160c5..315fb02e7b 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -52,9 +52,9 @@ class RoomCreationHandler(BaseHandler):
self.ratelimit(user_id)
if "room_alias_name" in config:
- room_alias = RoomAlias.create_local(
+ room_alias = RoomAlias.create(
config["room_alias_name"],
- self.hs
+ self.hs.hostname,
)
mapping = yield self.store.get_association_from_room_alias(
room_alias
@@ -77,7 +77,7 @@ class RoomCreationHandler(BaseHandler):
if room_id:
# Ensure room_id is the correct type
room_id_obj = RoomID.from_string(room_id, self.hs)
- if not room_id_obj.is_mine:
+ if not self.hs.is_mine(room_id_obj):
raise SynapseError(400, "Room id must be local")
yield self.store.store_room(
@@ -93,7 +93,10 @@ class RoomCreationHandler(BaseHandler):
while attempts < 5:
try:
random_string = stringutils.random_string(18)
- gen_room_id = RoomID.create_local(random_string, self.hs)
+ gen_room_id = RoomID.create(
+ random_string,
+ self.hs.hostname,
+ )
yield self.store.store_room(
room_id=gen_room_id.to_string(),
room_creator_user_id=user_id,
@@ -287,7 +290,7 @@ class RoomMemberHandler(BaseHandler):
if ignore_user is not None and member == ignore_user:
continue
- if member.is_mine:
+ if self.hs.is_mine(member):
if localusers is not None:
localusers.add(member)
else:
@@ -457,7 +460,7 @@ class RoomMemberHandler(BaseHandler):
prev_state.user_id, self.hs
)
- should_do_dance = not inviter.is_mine and not room
+ should_do_dance = not self.hs.is_mine(inviter) and not room
room_host = inviter.domain
else:
should_do_dance = False
@@ -504,7 +507,7 @@ class RoomMemberHandler(BaseHandler):
prev_state.sender, self.hs
)
- is_remote_invite_join = not inviter.is_mine and not room
+ is_remote_invite_join = not self.hs.is_mine(inviter) and not room
room_host = inviter.domain
else:
is_remote_invite_join = False
@@ -530,7 +533,7 @@ class RoomMemberHandler(BaseHandler):
# HS.
target_user_id = event.state_key
target_user = self.hs.parse_userid(target_user_id)
- if membership == Membership.INVITE and not target_user.is_mine:
+ if membership == Membership.INVITE and not self.hs.is_mine(target_user):
do_invite_host = target_user.domain
else:
do_invite_host = None
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index d88a53242c..be67fb2fc2 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -47,7 +47,7 @@ class TypingNotificationHandler(BaseHandler):
@defer.inlineCallbacks
def started_typing(self, target_user, auth_user, room_id, timeout):
- if not target_user.is_mine:
+ if not self.hs.is_mine(target_user):
raise SynapseError(400, "User is not hosted on this Home Server")
if target_user != auth_user:
@@ -72,7 +72,7 @@ class TypingNotificationHandler(BaseHandler):
@defer.inlineCallbacks
def stopped_typing(self, target_user, auth_user, room_id):
- if not target_user.is_mine:
+ if not self.hs.is_mine(target_user):
raise SynapseError(400, "User is not hosted on this Home Server")
if target_user != auth_user:
|