Procházet zdrojové kódy

remove /page-listing/info endpoint

Yuki Takei před 5 měsíci
rodič
revize
59629a35f8

+ 0 - 2
apps/app/src/features/opentelemetry/server/anonymization/handlers/page-listing-api-handler.spec.ts

@@ -15,11 +15,9 @@ describe('pageListingApiModule', () => {
       description                           | url                                                         | expected
       description                           | url                                                         | expected
       ${'ancestors-children endpoint'}      | ${'/_api/v3/page-listing/ancestors-children?path=/'}        | ${true}
       ${'ancestors-children endpoint'}      | ${'/_api/v3/page-listing/ancestors-children?path=/'}        | ${true}
       ${'children endpoint'}                | ${'/_api/v3/page-listing/children?path=/docs'}              | ${true}
       ${'children endpoint'}                | ${'/_api/v3/page-listing/children?path=/docs'}              | ${true}
-      ${'info endpoint'}                    | ${'/_api/v3/page-listing/info?path=/wiki'}                  | ${true}
       ${'item endpoint'}                    | ${'/_api/v3/page-listing/item?id=68b686d3984fce462ecc7c05'} | ${true}
       ${'item endpoint'}                    | ${'/_api/v3/page-listing/item?id=68b686d3984fce462ecc7c05'} | ${true}
       ${'ancestors-children without query'} | ${'/_api/v3/page-listing/ancestors-children'}               | ${true}
       ${'ancestors-children without query'} | ${'/_api/v3/page-listing/ancestors-children'}               | ${true}
       ${'children without query'}           | ${'/_api/v3/page-listing/children'}                         | ${true}
       ${'children without query'}           | ${'/_api/v3/page-listing/children'}                         | ${true}
-      ${'info without query'}               | ${'/_api/v3/page-listing/info'}                             | ${true}
       ${'item without query'}               | ${'/_api/v3/page-listing/item'}                             | ${true}
       ${'item without query'}               | ${'/_api/v3/page-listing/item'}                             | ${true}
       ${'other page-listing endpoint'}      | ${'/_api/v3/page-listing/other'}                            | ${false}
       ${'other page-listing endpoint'}      | ${'/_api/v3/page-listing/other'}                            | ${false}
       ${'different API version'}            | ${'/_api/v2/page-listing/children'}                         | ${false}
       ${'different API version'}            | ${'/_api/v2/page-listing/children'}                         | ${false}

+ 2 - 4
apps/app/src/features/opentelemetry/server/anonymization/handlers/page-listing-api-handler.ts

@@ -20,8 +20,7 @@ export const pageListingApiModule: AnonymizationModule = {
     return (
     return (
       url.includes('/_api/v3/page-listing/ancestors-children') ||
       url.includes('/_api/v3/page-listing/ancestors-children') ||
       url.includes('/_api/v3/page-listing/children') ||
       url.includes('/_api/v3/page-listing/children') ||
-      url.includes('/_api/v3/page-listing/item') ||
-      url.includes('/_api/v3/page-listing/info')
+      url.includes('/_api/v3/page-listing/item')
     );
     );
     // Add other page-listing endpoints here as needed
     // Add other page-listing endpoints here as needed
   },
   },
@@ -40,8 +39,7 @@ export const pageListingApiModule: AnonymizationModule = {
     if (
     if (
       url.includes('/_api/v3/page-listing/ancestors-children') ||
       url.includes('/_api/v3/page-listing/ancestors-children') ||
       url.includes('/_api/v3/page-listing/children') ||
       url.includes('/_api/v3/page-listing/children') ||
-      url.includes('/_api/v3/page-listing/item') ||
-      url.includes('/_api/v3/page-listing/info')
+      url.includes('/_api/v3/page-listing/item')
     ) {
     ) {
       const anonymizedUrl = anonymizeQueryParams(url, ['path']);
       const anonymizedUrl = anonymizeQueryParams(url, ['path']);
       // Only set attributes if the URL was actually modified
       // Only set attributes if the URL was actually modified

+ 0 - 117
apps/app/src/server/routes/apiv3/page-listing.ts

@@ -220,123 +220,6 @@ const routerFactory = (crowi: Crowi): Router => {
       }
       }
     });
     });
 
 
-  /**
-   * @swagger
-   *
-   * /page-listing/info:
-   *   get:
-   *     tags: [PageListing]
-   *     security:
-   *       - bearer: []
-   *       - accessTokenInQuery: []
-   *     summary: /page-listing/info
-   *     description: Get summary information of pages
-   *     parameters:
-   *       - name: pageIds
-   *         in: query
-   *         description: Array of page IDs to retrieve information for (One of pageIds or path is required)
-   *         schema:
-   *           type: array
-   *           items:
-   *             type: string
-   *       - name: path
-   *         in: query
-   *         description: Path of the page to retrieve information for (One of pageIds or path is required)
-   *         schema:
-   *           type: string
-   *       - name: attachBookmarkCount
-   *         in: query
-   *         schema:
-   *           type: boolean
-   *       - name: attachShortBody
-   *         in: query
-   *         schema:
-   *           type: boolean
-   *     responses:
-   *       200:
-   *         description: Get the information of a page
-   *         content:
-   *           application/json:
-   *             schema:
-   *               type: object
-   *               additionalProperties:
-   *                 $ref: '#/components/schemas/PageInfoAll'
-   */
-  router.get('/info',
-    accessTokenParser([SCOPE.READ.FEATURES.PAGE], { acceptLegacy: true }),
-    validator.pageIdsOrPathRequired, validator.infoParams, apiV3FormValidator, async(req: AuthorizedRequest, res: ApiV3Response) => {
-      const {
-        pageIds, path, attachBookmarkCount: attachBookmarkCountParam, attachShortBody: attachShortBodyParam,
-      } = req.query;
-
-      const attachBookmarkCount: boolean = attachBookmarkCountParam === 'true';
-      const attachShortBody: boolean = attachShortBodyParam === 'true';
-
-      const Page = mongoose.model<HydratedDocument<PageDocument>, PageModel>('Page');
-      // eslint-disable-next-line @typescript-eslint/no-explicit-any
-      const Bookmark = mongoose.model<any, any>('Bookmark');
-      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-      const pageService = crowi.pageService;
-      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-      const pageGrantService: IPageGrantService = crowi.pageGrantService!;
-
-      try {
-        const pages = pageIds != null
-          ? await Page.findByIdsAndViewer(pageIds as string[], req.user, null, true)
-          : await Page.findByPathAndViewer(path as string, req.user, null, false, true);
-
-        const foundIds = pages.map(page => page._id);
-
-        let shortBodiesMap;
-        if (attachShortBody) {
-          shortBodiesMap = await pageService.shortBodiesMapByPageIds(foundIds, req.user);
-        }
-
-        let bookmarkCountMap;
-        if (attachBookmarkCount) {
-          bookmarkCountMap = await Bookmark.getPageIdToCountMap(foundIds) as Record<string, number>;
-        }
-
-        const idToPageInfoMap: Record<string, IPageInfo | IPageInfoForListing> = {};
-
-        const isGuestUser = req.user == null;
-
-        const userRelatedGroups = await pageGrantService.getUserRelatedGroups(req.user);
-
-        for (const page of pages) {
-          const basicPageInfo = {
-            ...pageService.constructBasicPageInfo(page, isGuestUser),
-            bookmarkCount: bookmarkCountMap != null ? bookmarkCountMap[page._id.toString()] ?? 0 : 0,
-          };
-
-          // TODO: use pageService.getCreatorIdForCanDelete to get creatorId (https://redmine.weseek.co.jp/issues/140574)
-          const canDeleteCompletely = pageService.canDeleteCompletely(
-            page,
-            page.creator == null ? null : getIdForRef(page.creator),
-            req.user,
-            false,
-            userRelatedGroups,
-          ); // use normal delete config
-
-          const pageInfo = (!isIPageInfoForEntity(basicPageInfo))
-            ? basicPageInfo
-            : {
-              ...basicPageInfo,
-              isAbleToDeleteCompletely: canDeleteCompletely,
-              revisionShortBody: shortBodiesMap != null ? shortBodiesMap[page._id.toString()] : undefined,
-            } satisfies IPageInfoForListing;
-
-          idToPageInfoMap[page._id.toString()] = pageInfo;
-        }
-
-        return res.apiv3(idToPageInfoMap);
-      }
-      catch (err) {
-        logger.error('Error occurred while fetching page informations.', err);
-        return res.apiv3Err(new ErrorV3('Error occurred while fetching page informations.'));
-      }
-    });
-
   return router;
   return router;
 };
 };