mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 18:48:31 +01:00
refactor: reimplement limit with async
This commit is contained in:
parent
1d6d90d62d
commit
b3561ce425
1 changed files with 5 additions and 5 deletions
|
@ -43,9 +43,9 @@ export class RateLimiterService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public limit(limitation: IEndpointMeta['limit'] & { key: NonNullable<string> }, actor: string, factor = 1) {
|
public async limit(limitation: IEndpointMeta['limit'] & { key: NonNullable<string> }, actor: string, factor = 1) {
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Short-term limit
|
// Short-term limit
|
||||||
|
@ -97,11 +97,11 @@ export class RateLimiterService {
|
||||||
typeof limitation.max === 'number';
|
typeof limitation.max === 'number';
|
||||||
|
|
||||||
if (hasShortTermLimit) {
|
if (hasShortTermLimit) {
|
||||||
return min();
|
await min();
|
||||||
} else if (hasLongTermLimit) {
|
} else if (hasLongTermLimit) {
|
||||||
return max();
|
await max();
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue