Exemple #1
0
    async def on_GET(self, origin: str, content: Literal[None],
                     query: Dict[bytes, List[bytes]]) -> Tuple[int, JsonDict]:
        if not self.allow_access:
            raise FederationDeniedError(origin)

        limit = parse_integer_from_args(query, "limit", 0)
        since_token = parse_string_from_args(query, "since", None)
        include_all_networks = parse_boolean_from_args(query,
                                                       "include_all_networks",
                                                       default=False)
        third_party_instance_id = parse_string_from_args(
            query, "third_party_instance_id", None)

        if include_all_networks:
            network_tuple = None
        elif third_party_instance_id:
            network_tuple = ThirdPartyInstanceID.from_string(
                third_party_instance_id)
        else:
            network_tuple = ThirdPartyInstanceID(None, None)

        if limit == 0:
            # zero is a special value which corresponds to no limit.
            limit = None

        data = await self.handler.get_local_public_room_list(
            limit,
            since_token,
            network_tuple=network_tuple,
            from_federation=True)
        return 200, data
Exemple #2
0
    def on_GET(self, origin, content, query):
        if self.deny_access:
            raise FederationDeniedError(origin)

        limit = parse_integer_from_args(query, "limit", 0)
        since_token = parse_string_from_args(query, "since", None)
        include_all_networks = parse_boolean_from_args(
            query, "include_all_networks", False
        )
        third_party_instance_id = parse_string_from_args(
            query, "third_party_instance_id", None
        )

        if include_all_networks:
            network_tuple = None
        elif third_party_instance_id:
            network_tuple = ThirdPartyInstanceID.from_string(third_party_instance_id)
        else:
            network_tuple = ThirdPartyInstanceID(None, None)

        data = yield self.handler.get_local_public_room_list(
            limit, since_token,
            network_tuple=network_tuple,
            from_federation=True,
        )
        defer.returnValue((200, data))
Exemple #3
0
    async def on_GET(self, origin, content, query):
        if not self.allow_access:
            raise FederationDeniedError(origin)

        limit = parse_integer_from_args(query, "limit", 0)
        since_token = parse_string_from_args(query, "since", None)
        include_all_networks = parse_boolean_from_args(query,
                                                       "include_all_networks",
                                                       False)
        third_party_instance_id = parse_string_from_args(
            query, "third_party_instance_id", None)

        if include_all_networks:
            network_tuple = None
        elif third_party_instance_id:
            network_tuple = ThirdPartyInstanceID.from_string(
                third_party_instance_id)
        else:
            network_tuple = ThirdPartyInstanceID(None, None)

        data = await maybeDeferred(
            self.handler.get_local_public_room_list,
            limit,
            since_token,
            network_tuple=network_tuple,
            from_federation=True,
        )
        return 200, data
Exemple #4
0
    async def on_GET(
        self,
        origin: str,
        content: Literal[None],
        query: Mapping[bytes, Sequence[bytes]],
        room_id: str,
    ) -> Tuple[int, JsonDict]:
        suggested_only = parse_boolean_from_args(query,
                                                 "suggested_only",
                                                 default=False)

        max_rooms_per_space = parse_integer_from_args(query,
                                                      "max_rooms_per_space")
        if max_rooms_per_space is not None and max_rooms_per_space < 0:
            raise SynapseError(
                400,
                "Value for 'max_rooms_per_space' must be a non-negative integer",
                Codes.BAD_JSON,
            )

        exclude_rooms = parse_strings_from_args(query,
                                                "exclude_rooms",
                                                default=[])

        return 200, await self.handler.federation_space_summary(
            origin, room_id, suggested_only, max_rooms_per_space,
            exclude_rooms)
Exemple #5
0
 async def on_GET(
     self,
     origin: str,
     content: Literal[None],
     query: Mapping[bytes, Sequence[bytes]],
     room_id: str,
 ) -> Tuple[int, JsonDict]:
     suggested_only = parse_boolean_from_args(query,
                                              "suggested_only",
                                              default=False)
     return 200, await self.handler.get_federation_hierarchy(
         origin, room_id, suggested_only)
Exemple #6
0
    def on_GET(self, origin, content, query):
        limit = parse_integer_from_args(query, "limit", 0)
        since_token = parse_string_from_args(query, "since", None)
        include_all_networks = parse_boolean_from_args(query,
                                                       "include_all_networks",
                                                       False)
        third_party_instance_id = parse_string_from_args(
            query, "third_party_instance_id", None)

        if include_all_networks:
            network_tuple = None
        elif third_party_instance_id:
            network_tuple = ThirdPartyInstanceID.from_string(
                third_party_instance_id)
        else:
            network_tuple = ThirdPartyInstanceID(None, None)

        data = yield self.handler.get_local_public_room_list(
            limit, since_token, network_tuple=network_tuple)
        defer.returnValue((200, data))
Exemple #7
0
    async def on_PUT(
        self,
        origin: str,
        content: JsonDict,
        query: Dict[bytes, List[bytes]],
        room_id: str,
        event_id: str,
    ) -> Tuple[int, JsonDict]:
        # TODO(paul): assert that event_id parsed from path actually
        #   match those given in content

        partial_state = False
        if self._msc3706_enabled:
            partial_state = parse_boolean_from_args(
                query, "org.matrix.msc3706.partial_state", default=False)
        result = await self.handler.on_send_join_request(
            origin,
            content,
            room_id,
            caller_supports_partial_state=partial_state)
        return 200, result