Skip to content

Node.js based forum software built for the modern web

fix: add sourceContent prop to posts API; fix other tests

Julian Lame1db9642c22d
diff --git a/public/openapi/write/posts/pid.yaml b/public/openapi/write/posts/pid.yaml
index 45dba85c74..2203992b52 100644
--- a/public/openapi/write/posts/pid.yaml
+++ b/public/openapi/write/posts/pid.yaml
@@ -22,53 +22,65 @@ get:
status:
$ref: ../../components/schemas/Status.yaml#/Status
response:
- type: object
- properties:
- pid:
- type: number
- uid:
- type: number
- description: A user identifier
- tid:
- type: number
- description: A topic identifier
- content:
- type: string
- timestamp:
- type: number
- flagId:
- type: number
- deleted:
- type: number
- upvotes:
- type: number
- downvotes:
- type: number
- deleterUid:
- type: number
- edited:
- type: number
- replies:
- type: number
- bookmarks:
- type: number
- votes:
- type: number
- timestampISO:
- type: string
- description: An ISO 8601 formatted date string (complementing `timestamp`)
- editedISO:
- type: string
- description: An ISO 8601 formatted date string (complementing `timestamp`)
- upvoted:
- type: boolean
- downvoted:
- type: boolean
- attachments:
- type: array
- items:
- type: string
- description: A sha256 hash of the attachment (tied to the corresponding entry in the database)
+ allOf:
+ - type: object
+ properties:
+ pid:
+ type: number
+ uid:
+ type: number
+ description: A user identifier
+ tid:
+ type: number
+ description: A topic identifier
+ content:
+ type: string
+ timestamp:
+ type: number
+ flagId:
+ type: number
+ deleted:
+ type: number
+ upvotes:
+ type: number
+ downvotes:
+ type: number
+ deleterUid:
+ type: number
+ edited:
+ type: number
+ replies:
+ type: number
+ bookmarks:
+ type: number
+ votes:
+ type: number
+ timestampISO:
+ type: string
+ description: An ISO 8601 formatted date string (complementing `timestamp`)
+ editedISO:
+ type: string
+ description: An ISO 8601 formatted date string (complementing `timestamp`)
+ upvoted:
+ type: boolean
+ downvoted:
+ type: boolean
+ attachments:
+ type: array
+ items:
+ type: string
+ description: A sha256 hash of the attachment (tied to the corresponding entry in the database)
+ - type: object
+ description: Optional properties that may or may not be present (except for `pid`, which is always present, and is only here as a hack to pass validation)
+ properties:
+ pid:
+ type: number
+ description: A post identifier
+ sourceContent:
+ type: string
+ description: The markdown equivalent of a remote post content, as received (or fetched) from the remote site.
+ required:
+ - pid
put:
tags:
- posts
diff --git a/test/controllers.js b/test/controllers.js
index f4e2d850f5..d9e9f3e2a8 100644
--- a/test/controllers.js
+++ b/test/controllers.js
@@ -1915,12 +1915,12 @@ describe('Controllers', () => {
});
it('should deny access if view:users privilege is not enabled for guests', async () => {
- await privileges.global.rescind(['groups:view:users'], 'guests');
+ await privileges.global.rescind(['groups:view:users'], 'fediverse');
const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=acct:${username}@${nconf.get('url_parsed').host}`);
assert.strictEqual(response.statusCode, 400);
- await privileges.global.give(['groups:view:users'], 'guests');
+ await privileges.global.give(['groups:view:users'], 'fediverse');
});
it('should respond appropriately if the user requested does not exist locally', async () => {