id_access_token optional

pull/178/head
DevSymbioide 2 years ago
parent bf344ee3fd
commit 70c30a3fb0
  1. 2
      synapse/handlers/room_member.py
  2. 19
      synapse/rest/client/room.py
  3. 6
      synapse/storage/databases/main/registration.py
  4. 2
      synapse/types/__init__.py

@ -1569,7 +1569,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
id_server: str,
requester: Requester,
txn_id: Optional[str],
id_access_token: str,
id_access_token: Optional[str] = None, # watcha+
prev_event_ids: Optional[List[str]] = None,
depth: Optional[int] = None,
) -> Tuple[str, int]:

@ -1099,14 +1099,15 @@ class RoomMembershipRestServlet(TransactionRestServlet):
key in content for key in ("medium", "address")
):
missing_keys = [key for key in ("id_server", "id_access_token") if key not in content]
if not all(key in content for key in ("id_server", "id_access_token")):
missing_keys_str = ", ".join(missing_keys)
error_message = f"`{missing_keys_str}` {'is' if len(missing_keys) == 1 else 'are'} required when doing 3pid invite. Content: {content}"
raise SynapseError(
HTTPStatus.BAD_REQUEST,
error_message,
Codes.MISSING_PARAM,
)
if not requester.is_partner or (requester.is_partner and "id_server" in missing_keys): # watcha+
if not all(key in content for key in ("id_server", "id_access_token")):
missing_keys_str = ", ".join(missing_keys)
error_message = f"`{missing_keys_str}` {'is' if len(missing_keys) == 1 else 'are'} required when doing 3pid invite. Content: {content}"
raise SynapseError(
HTTPStatus.BAD_REQUEST,
error_message,
Codes.MISSING_PARAM,
)
try:
await self.room_member_handler.do_3pid_invite(
@ -1117,7 +1118,7 @@ class RoomMembershipRestServlet(TransactionRestServlet):
content["id_server"],
requester,
txn_id,
content["id_access_token"],
content.get("id_access_token"), # watcha+
)
except ShadowBanError:
# Pretend the request succeeded.

@ -97,7 +97,7 @@ class TokenLookupResult:
token_owner: str = attr.ib()
token_used: bool = False
is_partner: bool = False # watcha+
password_hash: bool = False
password_hash: bool = False # watcha+
# Make the token owner default to the user ID, which is the common case.
@token_owner.default
@ -255,7 +255,7 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
is_guest,
admin,
is_partner, # watcha+
password_hash,
password_hash, # watcha+
consent_version,
consent_ts,
consent_server_notice_sent,
@ -276,7 +276,7 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
creation_ts=creation_ts,
is_admin=bool(admin),
is_partner=bool(is_partner), # watcha+
password_hash=bool(password_hash),
password_hash=bool(password_hash), # watcha+
is_deactivated=bool(deactivated),
is_guest=bool(is_guest),
is_shadow_banned=bool(shadow_banned),

@ -1180,7 +1180,7 @@ class UserInfo:
approved: bool
locked: bool
is_partner: bool # watcha+
password_hash: bool
password_hash: bool # watcha+
class UserProfile(TypedDict):
user_id: str

Loading…
Cancel
Save