From c0248ca52b93c0854c2ba0fdc22d34c933c3ed90 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 25 Aug 2025 12:05:50 -0400 Subject: [PATCH] docs: openapi schema fixes for auto-categorization commits --- .../components/schemas/admin/rulesObject.yaml | 21 +++++++++++ .../openapi/read/admin/manage/categories.yaml | 2 ++ .../read/admin/settings/activitypub.yaml | 21 +++++++++++ .../write/admin/activitypub/rules.yaml | 36 +++++++++++++++++++ .../write/admin/activitypub/rules/rid.yaml | 25 +++++++++++++ src/controllers/admin/categories.js | 1 - 6 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 public/openapi/components/schemas/admin/rulesObject.yaml create mode 100644 public/openapi/write/admin/activitypub/rules.yaml create mode 100644 public/openapi/write/admin/activitypub/rules/rid.yaml diff --git a/public/openapi/components/schemas/admin/rulesObject.yaml b/public/openapi/components/schemas/admin/rulesObject.yaml new file mode 100644 index 0000000000..6b8db905ff --- /dev/null +++ b/public/openapi/components/schemas/admin/rulesObject.yaml @@ -0,0 +1,21 @@ +RulesObject: + type: array + items: + type: object + properties: + rid: + type: string + description: a valid rule ID + example: 4eb506f8-a173-4693-a41b-e23604bc973a + type: + type: string + description: The auto-categorization rule type + example: hashtag + value: + type: string + description: The value that incoming content will be matched against (used alongside `type`) + example: 'example' + cid: + type: number + description: The category ID of a local category + example: 1 \ No newline at end of file diff --git a/public/openapi/read/admin/manage/categories.yaml b/public/openapi/read/admin/manage/categories.yaml index b4e6102ac1..bbf8efb8fe 100644 --- a/public/openapi/read/admin/manage/categories.yaml +++ b/public/openapi/read/admin/manage/categories.yaml @@ -48,6 +48,8 @@ get: type: string order: type: number + isLocal: + type: boolean subCategoriesPerPage: type: number children: diff --git a/public/openapi/read/admin/settings/activitypub.yaml b/public/openapi/read/admin/settings/activitypub.yaml index b0871999b6..892c56030f 100644 --- a/public/openapi/read/admin/settings/activitypub.yaml +++ b/public/openapi/read/admin/settings/activitypub.yaml @@ -16,4 +16,25 @@ get: instanceCount: type: number description: The number of ActivityPub-enabled instances that this forum knows about. + rules: + type: array + items: + type: object + properties: + rid: + type: string + description: a valid rule ID + example: 4eb506f8-a173-4693-a41b-e23604bc973a + type: + type: string + description: The auto-categorization rule type + example: hashtag + value: + type: string + description: The value that incoming content will be matched against (used alongside `type`) + example: 'example' + cid: + type: number + description: The category ID of a local category + example: 1 - $ref: ../../../components/schemas/CommonProps.yaml#/CommonProps \ No newline at end of file diff --git a/public/openapi/write/admin/activitypub/rules.yaml b/public/openapi/write/admin/activitypub/rules.yaml new file mode 100644 index 0000000000..46473530a8 --- /dev/null +++ b/public/openapi/write/admin/activitypub/rules.yaml @@ -0,0 +1,36 @@ +post: + tags: + - admin + summary: create auto-categorization rule + description: This operation creates a new auto-categorization rule that is applied to new remote content received via ActivityPub. + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + type: + type: string + description: The auto-categorization rule type + example: hashtag + value: + type: string + description: The value that incoming content will be matched against (used alongside `type`) + example: 'example' + cid: + type: number + description: The category ID of a local category + example: 1 + responses: + '200': + description: rule successfully created + content: + application/json: + schema: + type: object + properties: + status: + $ref: ../../components/schemas/Status.yaml#/Status + response: + $ref: ../../components/schemas/admin/rulesObject.yaml#/RulesObject diff --git a/public/openapi/write/admin/activitypub/rules/rid.yaml b/public/openapi/write/admin/activitypub/rules/rid.yaml new file mode 100644 index 0000000000..72f71149da --- /dev/null +++ b/public/openapi/write/admin/activitypub/rules/rid.yaml @@ -0,0 +1,25 @@ +delete: + tags: + - admin + summary: delete auto-categorization rule + description: This operation deletes a previously set-up auto-categorization rule + parameters: + - in: path + name: rid + schema: + type: string + required: true + description: a valid rule ID + example: 4eb506f8-a173-4693-a41b-e23604bc973a + responses: + '200': + description: rule successfully deleted + content: + application/json: + schema: + type: object + properties: + status: + $ref: ../../../components/schemas/Status.yaml#/Status + response: + $ref: ../../components/schemas/admin/rulesObject.yaml#/RulesObject diff --git a/src/controllers/admin/categories.js b/src/controllers/admin/categories.js index 95d8376882..e6bb7aaa41 100644 --- a/src/controllers/admin/categories.js +++ b/src/controllers/admin/categories.js @@ -72,7 +72,6 @@ categoriesController.getAll = async function (req, res) { let categoriesData = await categories.getCategoriesFields(cids, fields); ({ categories: categoriesData } = await plugins.hooks.fire('filter:admin.categories.get', { categories: categoriesData, fields: fields })); - // Append remote categories categoriesData = categoriesData.map((category) => { category.isLocal = utils.isNumber(category.cid); return category;