Move API request limits into the generic ApiClient

Currently only affects MisskeyApiClient, as Mastodon-flavour API is
constraint by a server-side hard limit of 40 replies.
Prepares for implementing multi-part requests which will allow
Mastodon-flavour clients to also follow the same limits.
This commit is contained in:
Oneric 2023-10-19 15:01:04 +02:00
parent 30dc06657c
commit 79e358ccb1

View file

@ -152,6 +152,11 @@ class ApiClient {
*/
constructor(instance) {
this._instance = instance;
// How many objects to max consider per type
this._CNT_NOTES = 70;
this._CNT_RENOTES = 50;
this._CNT_REPLIES = 100;
this._CNT_FAVS = 100;
}
/**
@ -626,7 +631,7 @@ class MisskeyApiClient extends ApiClient {
},
body: {
userId: user.id,
limit: 70,
limit: this._CNT_NOTES,
reply: false,
renote: false,
}
@ -656,7 +661,7 @@ class MisskeyApiClient extends ApiClient {
},
body: {
noteId: note.id,
limit: 50,
limit: this._CNT_RENOTES,
}
});
@ -682,7 +687,7 @@ class MisskeyApiClient extends ApiClient {
},
body: {
noteId: note.id,
limit: 100,
limit: this._CNT_REPLIES,
}
});
@ -720,7 +725,7 @@ class MisskeyApiClient extends ApiClient {
},
body: {
noteId: note.id,
limit: 100,
limit: this._CNT_FAVS,
}
});