From b033328ee4ac065e6971f4b5a0bc513380eae614 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 5 Jul 2023 17:31:39 +0200 Subject: [PATCH] Default to limit=20 for many endpoints --- megalodon/src/misskey.ts | 81 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/megalodon/src/misskey.ts b/megalodon/src/misskey.ts index 8dc65ba..8ee9a20 100644 --- a/megalodon/src/misskey.ts +++ b/megalodon/src/misskey.ts @@ -339,6 +339,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -364,6 +369,10 @@ export default class Misskey implements MegalodonInterface { withFiles: options.only_media }) } + } else { + params = Object.assign(params, { + limit: 20 + }) } return this.client.post>('/api/users/notes', params).then(async res => { const statuses: Array = await Promise.all(res.data.map(note => this.noteWithMentions(note, this.baseUrlToHost(this.baseUrl)))) @@ -1326,6 +1335,7 @@ export default class Misskey implements MegalodonInterface { } public async getStatusHistory(): Promise>> { + // FIXME: stub, implement once we have note edit history in the database const history : Entity.StatusEdit[] = []; const res : Response = { headers: undefined, @@ -1336,7 +1346,6 @@ export default class Misskey implements MegalodonInterface { return new Promise(resolve => resolve(res)) } - /** * POST /api/notes/renotes */ @@ -1634,6 +1643,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -1650,6 +1664,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/notes/global-timeline', params) .then(async res => ({ @@ -1680,6 +1699,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -1696,6 +1720,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/notes/local-timeline', params) .then(async res => ({ @@ -1732,6 +1761,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -1748,6 +1782,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/notes/search-by-tag', params) .then(async res => ({ @@ -1775,6 +1814,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -1791,6 +1835,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/notes/timeline', params) .then(async res => ({ @@ -1821,6 +1870,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -1837,6 +1891,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/notes/user-list-timeline', params) .then(async res => ({ ...res, data: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl)))) })) @@ -1863,6 +1922,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -1879,6 +1943,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/notes/mentions', params) .then(res => ({ ...res, data: res.data.map(n => this.converter.noteToConversation(n, this.baseUrlToHost(this.baseUrl))) })) @@ -2033,6 +2102,11 @@ export default class Misskey implements MegalodonInterface { limit: options.limit }) } + else { + params = Object.assign(params, { + limit: 20 + }) + } if (options.max_id) { params = Object.assign(params, { untilId: options.max_id @@ -2054,6 +2128,11 @@ export default class Misskey implements MegalodonInterface { }) } } + else { + params = Object.assign(params, { + limit: 20 + }) + } return this.client .post>('/api/i/notifications', params) .then(res => ({ ...res, data: res.data.map(n => this.converter.notification(n, this.baseUrlToHost(this.baseUrl))) }))