mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Use update_membership for profile updates
This commit is contained in:
parent
1bbb67c452
commit
8168341e9b
@ -16,8 +16,7 @@
|
|||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.errors import SynapseError, AuthError, CodeMessageException
|
from synapse.api.errors import SynapseError, AuthError, CodeMessageException
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.types import UserID, Requester
|
||||||
from synapse.types import UserID
|
|
||||||
from synapse.util import unwrapFirstError
|
from synapse.util import unwrapFirstError
|
||||||
|
|
||||||
from ._base import BaseHandler
|
from ._base import BaseHandler
|
||||||
@ -208,21 +207,18 @@ class ProfileHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for j in joins:
|
for j in joins:
|
||||||
content = {
|
handler = self.hs.get_handlers().room_member_handler
|
||||||
"membership": Membership.JOIN,
|
|
||||||
}
|
|
||||||
|
|
||||||
yield collect_presencelike_data(self.distributor, user, content)
|
|
||||||
|
|
||||||
msg_handler = self.hs.get_handlers().message_handler
|
|
||||||
try:
|
try:
|
||||||
yield msg_handler.create_and_send_event({
|
# Assume the user isn't a guest because we don't let guests set
|
||||||
"type": EventTypes.Member,
|
# profile or avatar data.
|
||||||
"room_id": j.room_id,
|
requester = Requester(user, "", False)
|
||||||
"state_key": user.to_string(),
|
yield handler.update_membership(
|
||||||
"content": content,
|
requester,
|
||||||
"sender": user.to_string()
|
user,
|
||||||
}, ratelimit=False)
|
j.room_id,
|
||||||
|
"join", # We treat a profile update like a join.
|
||||||
|
ratelimit=False,
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Failed to update join event for room %s - %s",
|
"Failed to update join event for room %s - %s",
|
||||||
|
@ -41,10 +41,6 @@ logger = logging.getLogger(__name__)
|
|||||||
id_server_scheme = "https://"
|
id_server_scheme = "https://"
|
||||||
|
|
||||||
|
|
||||||
def collect_presencelike_data(distributor, user, content):
|
|
||||||
return distributor.fire("collect_presencelike_data", user, content)
|
|
||||||
|
|
||||||
|
|
||||||
def user_left_room(distributor, user, room_id):
|
def user_left_room(distributor, user, room_id):
|
||||||
return preserve_context_over_fn(
|
return preserve_context_over_fn(
|
||||||
distributor.fire,
|
distributor.fire,
|
||||||
|
Loading…
Reference in New Issue
Block a user