Default to limit=20 for many endpoints

This commit is contained in:
Laura Hausmann 2023-07-05 17:31:39 +02:00
parent 30d6ae45f3
commit b033328ee4
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -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<Array<MisskeyAPI.Entity.Note>>('/api/users/notes', params).then(async res => {
const statuses: Array<Entity.Status> = 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<Response<Array<Entity.StatusEdit>>> {
// 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<Array<MisskeyAPI.Entity.Note>>('/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<Array<MisskeyAPI.Entity.Note>>('/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<Array<MisskeyAPI.Entity.Note>>('/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<Array<MisskeyAPI.Entity.Note>>('/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<Array<MisskeyAPI.Entity.Note>>('/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<Array<MisskeyAPI.Entity.Note>>('/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<Array<MisskeyAPI.Entity.Notification>>('/api/i/notifications', params)
.then(res => ({ ...res, data: res.data.map(n => this.converter.notification(n, this.baseUrlToHost(this.baseUrl))) }))