示例#1
0
    async def on_GET(self, request):
        requester = await self.auth.get_user_by_req(request,
                                                    rights="delete_pusher")
        user = requester.user

        app_id = parse_string(request, "app_id", required=True)
        pushkey = parse_string(request, "pushkey", required=True)

        try:
            await self.pusher_pool.remove_pusher(app_id=app_id,
                                                 pushkey=pushkey,
                                                 user_id=user.to_string())
        except StoreError as se:
            if se.code != 404:
                # This is fine: they're already unsubscribed
                raise

        self.notifier.on_new_replication_data()

        respond_with_html_bytes(
            request,
            200,
            PushersRemoveRestServlet.SUCCESS_HTML,
        )
        return None
示例#2
0
    async def _async_render_GET(self, request: SynapseRequest) -> None:
        token = parse_string(request, "access_token", required=True)
        app_id = parse_string(request, "app_id", required=True)
        pushkey = parse_string(request, "pushkey", required=True)

        user_id = self.macaroon_generator.verify_delete_pusher_token(
            token, app_id, pushkey)

        try:
            await self.pusher_pool.remove_pusher(app_id=app_id,
                                                 pushkey=pushkey,
                                                 user_id=user_id)
        except StoreError as se:
            if se.code != 404:
                # This is fine: they're already unsubscribed
                raise

        self.notifier.on_new_replication_data()

        respond_with_html_bytes(
            request,
            200,
            UnsubscribeResource.SUCCESS_HTML,
        )