mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Merge pull request #708 from matrix-org/markjh/remove_collect_presencelike_data
Call profile handler get_displayname directly
This commit is contained in:
commit
b4a5002a6e
@ -34,10 +34,6 @@ import logging
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def collect_presencelike_data(distributor, user, content):
|
|
||||||
return distributor.fire("collect_presencelike_data", user, content)
|
|
||||||
|
|
||||||
|
|
||||||
class MessageHandler(BaseHandler):
|
class MessageHandler(BaseHandler):
|
||||||
|
|
||||||
def __init__(self, hs):
|
def __init__(self, hs):
|
||||||
@ -202,12 +198,8 @@ class MessageHandler(BaseHandler):
|
|||||||
membership = builder.content.get("membership", None)
|
membership = builder.content.get("membership", None)
|
||||||
target = UserID.from_string(builder.state_key)
|
target = UserID.from_string(builder.state_key)
|
||||||
|
|
||||||
if membership == Membership.JOIN:
|
if membership in {Membership.JOIN, Membership.INVITE}:
|
||||||
# If event doesn't include a display name, add one.
|
# If event doesn't include a display name, add one.
|
||||||
yield collect_presencelike_data(
|
|
||||||
self.distributor, target, builder.content
|
|
||||||
)
|
|
||||||
elif membership == Membership.INVITE:
|
|
||||||
profile = self.hs.get_handlers().profile_handler
|
profile = self.hs.get_handlers().profile_handler
|
||||||
content = builder.content
|
content = builder.content
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ from twisted.internet import defer
|
|||||||
|
|
||||||
from synapse.api.errors import SynapseError, AuthError, CodeMessageException
|
from synapse.api.errors import SynapseError, AuthError, CodeMessageException
|
||||||
from synapse.types import UserID, Requester
|
from synapse.types import UserID, Requester
|
||||||
from synapse.util import unwrapFirstError
|
|
||||||
|
|
||||||
from ._base import BaseHandler
|
from ._base import BaseHandler
|
||||||
|
|
||||||
@ -31,10 +30,6 @@ def changed_presencelike_data(distributor, user, state):
|
|||||||
return distributor.fire("changed_presencelike_data", user, state)
|
return distributor.fire("changed_presencelike_data", user, state)
|
||||||
|
|
||||||
|
|
||||||
def collect_presencelike_data(distributor, user, content):
|
|
||||||
return distributor.fire("collect_presencelike_data", user, content)
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileHandler(BaseHandler):
|
class ProfileHandler(BaseHandler):
|
||||||
|
|
||||||
def __init__(self, hs):
|
def __init__(self, hs):
|
||||||
@ -48,15 +43,10 @@ class ProfileHandler(BaseHandler):
|
|||||||
distributor = hs.get_distributor()
|
distributor = hs.get_distributor()
|
||||||
self.distributor = distributor
|
self.distributor = distributor
|
||||||
|
|
||||||
distributor.declare("collect_presencelike_data")
|
|
||||||
distributor.declare("changed_presencelike_data")
|
distributor.declare("changed_presencelike_data")
|
||||||
|
|
||||||
distributor.observe("registered_user", self.registered_user)
|
distributor.observe("registered_user", self.registered_user)
|
||||||
|
|
||||||
distributor.observe(
|
|
||||||
"collect_presencelike_data", self.collect_presencelike_data
|
|
||||||
)
|
|
||||||
|
|
||||||
def registered_user(self, user):
|
def registered_user(self, user):
|
||||||
return self.store.create_profile(user.localpart)
|
return self.store.create_profile(user.localpart)
|
||||||
|
|
||||||
@ -158,24 +148,6 @@ class ProfileHandler(BaseHandler):
|
|||||||
|
|
||||||
yield self._update_join_states(requester)
|
yield self._update_join_states(requester)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def collect_presencelike_data(self, user, state):
|
|
||||||
if not self.hs.is_mine(user):
|
|
||||||
defer.returnValue(None)
|
|
||||||
|
|
||||||
(displayname, avatar_url) = yield defer.gatherResults(
|
|
||||||
[
|
|
||||||
self.store.get_profile_displayname(user.localpart),
|
|
||||||
self.store.get_profile_avatar_url(user.localpart),
|
|
||||||
],
|
|
||||||
consumeErrors=True
|
|
||||||
).addErrback(unwrapFirstError)
|
|
||||||
|
|
||||||
state["displayname"] = displayname
|
|
||||||
state["avatar_url"] = avatar_url
|
|
||||||
|
|
||||||
defer.returnValue(None)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_profile_query(self, args):
|
def on_profile_query(self, args):
|
||||||
user = UserID.from_string(args["user_id"])
|
user = UserID.from_string(args["user_id"])
|
||||||
|
Loading…
Reference in New Issue
Block a user