mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 02:43:54 +01:00
Merge pull request #788 from matrix-org/markjh/domian
Spell "domain" correctly
This commit is contained in:
commit
3fd8a07fca
6 changed files with 19 additions and 19 deletions
|
@ -22,7 +22,7 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.constants import EventTypes, Membership, JoinRules
|
from synapse.api.constants import EventTypes, Membership, JoinRules
|
||||||
from synapse.api.errors import AuthError, Codes, SynapseError, EventSizeError
|
from synapse.api.errors import AuthError, Codes, SynapseError, EventSizeError
|
||||||
from synapse.types import Requester, UserID, get_domian_from_id
|
from synapse.types import Requester, UserID, get_domain_from_id
|
||||||
from synapse.util.logutils import log_function
|
from synapse.util.logutils import log_function
|
||||||
from synapse.util.logcontext import preserve_context_over_fn
|
from synapse.util.logcontext import preserve_context_over_fn
|
||||||
from synapse.util.metrics import Measure
|
from synapse.util.metrics import Measure
|
||||||
|
@ -91,8 +91,8 @@ class Auth(object):
|
||||||
"Room %r does not exist" % (event.room_id,)
|
"Room %r does not exist" % (event.room_id,)
|
||||||
)
|
)
|
||||||
|
|
||||||
creating_domain = get_domian_from_id(event.room_id)
|
creating_domain = get_domain_from_id(event.room_id)
|
||||||
originating_domain = get_domian_from_id(event.sender)
|
originating_domain = get_domain_from_id(event.sender)
|
||||||
if creating_domain != originating_domain:
|
if creating_domain != originating_domain:
|
||||||
if not self.can_federate(event, auth_events):
|
if not self.can_federate(event, auth_events):
|
||||||
raise AuthError(
|
raise AuthError(
|
||||||
|
@ -219,7 +219,7 @@ class Auth(object):
|
||||||
for event in curr_state.values():
|
for event in curr_state.values():
|
||||||
if event.type == EventTypes.Member:
|
if event.type == EventTypes.Member:
|
||||||
try:
|
try:
|
||||||
if get_domian_from_id(event.state_key) != host:
|
if get_domain_from_id(event.state_key) != host:
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
logger.warn("state_key not user_id: %s", event.state_key)
|
logger.warn("state_key not user_id: %s", event.state_key)
|
||||||
|
@ -266,8 +266,8 @@ class Auth(object):
|
||||||
|
|
||||||
target_user_id = event.state_key
|
target_user_id = event.state_key
|
||||||
|
|
||||||
creating_domain = get_domian_from_id(event.room_id)
|
creating_domain = get_domain_from_id(event.room_id)
|
||||||
target_domain = get_domian_from_id(target_user_id)
|
target_domain = get_domain_from_id(target_user_id)
|
||||||
if creating_domain != target_domain:
|
if creating_domain != target_domain:
|
||||||
if not self.can_federate(event, auth_events):
|
if not self.can_federate(event, auth_events):
|
||||||
raise AuthError(
|
raise AuthError(
|
||||||
|
@ -890,8 +890,8 @@ class Auth(object):
|
||||||
if user_level >= redact_level:
|
if user_level >= redact_level:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
redacter_domain = get_domian_from_id(event.event_id)
|
redacter_domain = get_domain_from_id(event.event_id)
|
||||||
redactee_domain = get_domian_from_id(event.redacts)
|
redactee_domain = get_domain_from_id(event.redacts)
|
||||||
if redacter_domain == redactee_domain:
|
if redacter_domain == redactee_domain:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ from synapse.util.frozenutils import unfreeze
|
||||||
from synapse.crypto.event_signing import (
|
from synapse.crypto.event_signing import (
|
||||||
compute_event_signature, add_hashes_and_signatures,
|
compute_event_signature, add_hashes_and_signatures,
|
||||||
)
|
)
|
||||||
from synapse.types import UserID, get_domian_from_id
|
from synapse.types import UserID, get_domain_from_id
|
||||||
|
|
||||||
from synapse.events.utils import prune_event
|
from synapse.events.utils import prune_event
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ class FederationHandler(BaseHandler):
|
||||||
joined_domains = {}
|
joined_domains = {}
|
||||||
for u, d in joined_users:
|
for u, d in joined_users:
|
||||||
try:
|
try:
|
||||||
dom = get_domian_from_id(u)
|
dom = get_domain_from_id(u)
|
||||||
old_d = joined_domains.get(dom)
|
old_d = joined_domains.get(dom)
|
||||||
if old_d:
|
if old_d:
|
||||||
joined_domains[dom] = min(d, old_d)
|
joined_domains[dom] = min(d, old_d)
|
||||||
|
@ -744,7 +744,7 @@ class FederationHandler(BaseHandler):
|
||||||
try:
|
try:
|
||||||
if k[0] == EventTypes.Member:
|
if k[0] == EventTypes.Member:
|
||||||
if s.content["membership"] == Membership.JOIN:
|
if s.content["membership"] == Membership.JOIN:
|
||||||
destinations.add(get_domian_from_id(s.state_key))
|
destinations.add(get_domain_from_id(s.state_key))
|
||||||
except:
|
except:
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Failed to get destination from event %s", s.event_id
|
"Failed to get destination from event %s", s.event_id
|
||||||
|
@ -970,7 +970,7 @@ class FederationHandler(BaseHandler):
|
||||||
try:
|
try:
|
||||||
if k[0] == EventTypes.Member:
|
if k[0] == EventTypes.Member:
|
||||||
if s.content["membership"] == Membership.LEAVE:
|
if s.content["membership"] == Membership.LEAVE:
|
||||||
destinations.add(get_domian_from_id(s.state_key))
|
destinations.add(get_domain_from_id(s.state_key))
|
||||||
except:
|
except:
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Failed to get destination from event %s", s.event_id
|
"Failed to get destination from event %s", s.event_id
|
||||||
|
|
|
@ -23,7 +23,7 @@ from synapse.events.validator import EventValidator
|
||||||
from synapse.push.action_generator import ActionGenerator
|
from synapse.push.action_generator import ActionGenerator
|
||||||
from synapse.streams.config import PaginationConfig
|
from synapse.streams.config import PaginationConfig
|
||||||
from synapse.types import (
|
from synapse.types import (
|
||||||
UserID, RoomAlias, RoomStreamToken, StreamToken, get_domian_from_id
|
UserID, RoomAlias, RoomStreamToken, StreamToken, get_domain_from_id
|
||||||
)
|
)
|
||||||
from synapse.util import unwrapFirstError
|
from synapse.util import unwrapFirstError
|
||||||
from synapse.util.async import concurrently_execute
|
from synapse.util.async import concurrently_execute
|
||||||
|
@ -902,7 +902,7 @@ class MessageHandler(BaseHandler):
|
||||||
try:
|
try:
|
||||||
if k[0] == EventTypes.Member:
|
if k[0] == EventTypes.Member:
|
||||||
if s.content["membership"] == Membership.JOIN:
|
if s.content["membership"] == Membership.JOIN:
|
||||||
destinations.add(get_domian_from_id(s.state_key))
|
destinations.add(get_domain_from_id(s.state_key))
|
||||||
except SynapseError:
|
except SynapseError:
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Failed to get destination from event %s", s.event_id
|
"Failed to get destination from event %s", s.event_id
|
||||||
|
|
|
@ -33,7 +33,7 @@ from synapse.util.logcontext import preserve_fn
|
||||||
from synapse.util.logutils import log_function
|
from synapse.util.logutils import log_function
|
||||||
from synapse.util.metrics import Measure
|
from synapse.util.metrics import Measure
|
||||||
from synapse.util.wheel_timer import WheelTimer
|
from synapse.util.wheel_timer import WheelTimer
|
||||||
from synapse.types import UserID, get_domian_from_id
|
from synapse.types import UserID, get_domain_from_id
|
||||||
import synapse.metrics
|
import synapse.metrics
|
||||||
|
|
||||||
from ._base import BaseHandler
|
from ._base import BaseHandler
|
||||||
|
@ -440,7 +440,7 @@ class PresenceHandler(BaseHandler):
|
||||||
if not local_states:
|
if not local_states:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
host = get_domian_from_id(user_id)
|
host = get_domain_from_id(user_id)
|
||||||
hosts_to_states.setdefault(host, []).extend(local_states)
|
hosts_to_states.setdefault(host, []).extend(local_states)
|
||||||
|
|
||||||
# TODO: de-dup hosts_to_states, as a single host might have multiple
|
# TODO: de-dup hosts_to_states, as a single host might have multiple
|
||||||
|
|
|
@ -21,7 +21,7 @@ from ._base import SQLBaseStore
|
||||||
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks
|
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks
|
||||||
|
|
||||||
from synapse.api.constants import Membership
|
from synapse.api.constants import Membership
|
||||||
from synapse.types import get_domian_from_id
|
from synapse.types import get_domain_from_id
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ class RoomMemberStore(SQLBaseStore):
|
||||||
room_id, membership=Membership.JOIN
|
room_id, membership=Membership.JOIN
|
||||||
)
|
)
|
||||||
|
|
||||||
joined_domains = set(get_domian_from_id(r["user_id"]) for r in rows)
|
joined_domains = set(get_domain_from_id(r["user_id"]) for r in rows)
|
||||||
|
|
||||||
return joined_domains
|
return joined_domains
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ from collections import namedtuple
|
||||||
Requester = namedtuple("Requester", ["user", "access_token_id", "is_guest"])
|
Requester = namedtuple("Requester", ["user", "access_token_id", "is_guest"])
|
||||||
|
|
||||||
|
|
||||||
def get_domian_from_id(string):
|
def get_domain_from_id(string):
|
||||||
return string.split(":", 1)[1]
|
return string.split(":", 1)[1]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue