示例#1
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))
示例#2
0
文件: __init__.py 项目: Fnux/synapse
    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
示例#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
示例#4
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)
     data = yield self.room_list_handler.get_local_public_room_list(
         limit, since_token
     )
     defer.returnValue((200, data))
示例#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)

        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)
示例#6
0
    def on_GET(self, origin, content, query, context):
        versions = [x.decode('ascii') for x in query[b"v"]]
        limit = parse_integer_from_args(query, "limit", None)

        if not limit:
            return defer.succeed((400, {"error": "Did not include limit param"}))

        return self.handler.on_backfill_request(origin, context, versions, limit)
示例#7
0
    def on_GET(self, origin, content, query, context):
        versions = [x.decode('ascii') for x in query[b"v"]]
        limit = parse_integer_from_args(query, "limit", None)

        if not limit:
            return defer.succeed((400, {"error": "Did not include limit param"}))

        return self.handler.on_backfill_request(origin, context, versions, limit)
示例#8
0
    async def on_GET(
        self,
        origin: str,
        content: Literal[None],
        query: Dict[bytes, List[bytes]],
        room_id: str,
    ) -> Tuple[int, JsonDict]:
        versions = [x.decode("ascii") for x in query[b"v"]]
        limit = parse_integer_from_args(query, "limit", None)

        if not limit:
            return 400, {"error": "Did not include limit param"}

        return await self.handler.on_backfill_request(origin, room_id,
                                                      versions, limit)
示例#9
0
    async def on_GET(
        self,
        origin: str,
        content: Literal[None],
        query: Dict[bytes, List[bytes]],
        room_id: str,
    ) -> Tuple[int, JsonDict]:
        timestamp = parse_integer_from_args(query, "ts", required=True)
        direction = parse_string_from_args(query,
                                           "dir",
                                           default="f",
                                           allowed_values=["f", "b"],
                                           required=True)

        return await self.handler.on_timestamp_to_event_request(
            origin, room_id, timestamp, direction)
示例#10
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))