mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-19 17:13:31 -04:00
Add a way to skip the rate limiter on ack.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "5.1.0-alpha.3",
|
||||
"version": "5.1.0-alpha.4",
|
||||
"main": "dist/index.js",
|
||||
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
|
||||
"author": "Paul Makles <insrt.uk>",
|
||||
|
||||
@@ -420,15 +420,16 @@ export class Channel {
|
||||
/**
|
||||
* Mark a channel as read
|
||||
* @param message Last read message or its ID
|
||||
* @param skipRateLimiter Whether to skip the internal rate limiter
|
||||
*/
|
||||
async ack(message?: Message | string) {
|
||||
async ack(message?: Message | string, skipRateLimiter?: boolean) {
|
||||
const id = (typeof message === 'string' ? message : message?._id) ?? this.last_message_id ?? ulid();
|
||||
const performAck = () => {
|
||||
delete this.ackLimit;
|
||||
this.client.req('PUT', `/channels/${this._id}/ack/${id}` as '/channels/id/ack/id');
|
||||
}
|
||||
|
||||
if (!this.client.options.ackRateLimiter) return performAck();
|
||||
if (!this.client.options.ackRateLimiter || skipRateLimiter) return performAck();
|
||||
|
||||
clearTimeout(this.ackTimeout);
|
||||
if (this.ackLimit && + new Date() > this.ackLimit) {
|
||||
|
||||
Reference in New Issue
Block a user