Merge pull request #645 from matrix-org/erikj/3pid_guest_config
Add config to create guest account on 3pid invite
This commit is contained in:
commit
6b1e9b8dfe
|
@ -37,6 +37,10 @@ class RegistrationConfig(Config):
|
||||||
self.trusted_third_party_id_servers = config["trusted_third_party_id_servers"]
|
self.trusted_third_party_id_servers = config["trusted_third_party_id_servers"]
|
||||||
self.allow_guest_access = config.get("allow_guest_access", False)
|
self.allow_guest_access = config.get("allow_guest_access", False)
|
||||||
|
|
||||||
|
self.invite_3pid_guest = (
|
||||||
|
self.allow_guest_access and config.get("invite_3pid_guest", False)
|
||||||
|
)
|
||||||
|
|
||||||
def default_config(self, **kwargs):
|
def default_config(self, **kwargs):
|
||||||
registration_shared_secret = random_string_with_symbols(50)
|
registration_shared_secret = random_string_with_symbols(50)
|
||||||
|
|
||||||
|
|
|
@ -877,6 +877,24 @@ class RoomMemberHandler(BaseHandler):
|
||||||
user.
|
user.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
is_url = "%s%s/_matrix/identity/api/v1/store-invite" % (
|
||||||
|
id_server_scheme, id_server,
|
||||||
|
)
|
||||||
|
|
||||||
|
invite_config = {
|
||||||
|
"medium": medium,
|
||||||
|
"address": address,
|
||||||
|
"room_id": room_id,
|
||||||
|
"room_alias": room_alias,
|
||||||
|
"room_avatar_url": room_avatar_url,
|
||||||
|
"room_join_rules": room_join_rules,
|
||||||
|
"room_name": room_name,
|
||||||
|
"sender": inviter_user_id,
|
||||||
|
"sender_display_name": inviter_display_name,
|
||||||
|
"sender_avatar_url": inviter_avatar_url,
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.hs.config.invite_3pid_guest:
|
||||||
registration_handler = self.hs.get_handlers().registration_handler
|
registration_handler = self.hs.get_handlers().registration_handler
|
||||||
guest_access_token = yield registration_handler.guest_access_token_for(
|
guest_access_token = yield registration_handler.guest_access_token_for(
|
||||||
medium=medium,
|
medium=medium,
|
||||||
|
@ -888,25 +906,14 @@ class RoomMemberHandler(BaseHandler):
|
||||||
guest_access_token
|
guest_access_token
|
||||||
)
|
)
|
||||||
|
|
||||||
is_url = "%s%s/_matrix/identity/api/v1/store-invite" % (
|
invite_config.update({
|
||||||
id_server_scheme, id_server,
|
"guest_access_token": guest_access_token,
|
||||||
)
|
"guest_user_id": guest_user_info["user"].to_string(),
|
||||||
|
})
|
||||||
|
|
||||||
data = yield self.hs.get_simple_http_client().post_urlencoded_get_json(
|
data = yield self.hs.get_simple_http_client().post_urlencoded_get_json(
|
||||||
is_url,
|
is_url,
|
||||||
{
|
invite_config
|
||||||
"medium": medium,
|
|
||||||
"address": address,
|
|
||||||
"room_id": room_id,
|
|
||||||
"room_alias": room_alias,
|
|
||||||
"room_avatar_url": room_avatar_url,
|
|
||||||
"room_join_rules": room_join_rules,
|
|
||||||
"room_name": room_name,
|
|
||||||
"sender": inviter_user_id,
|
|
||||||
"sender_display_name": inviter_display_name,
|
|
||||||
"sender_avatar_url": inviter_avatar_url,
|
|
||||||
"guest_user_id": guest_user_info["user"].to_string(),
|
|
||||||
"guest_access_token": guest_access_token,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
# TODO: Check for success
|
# TODO: Check for success
|
||||||
token = data["token"]
|
token = data["token"]
|
||||||
|
|
Loading…
Reference in New Issue