mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 03:40:25 +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
|
||||
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) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// Short-term limit
|
||||
|
@ -97,11 +97,11 @@ export class RateLimiterService {
|
|||
typeof limitation.max === 'number';
|
||||
|
||||
if (hasShortTermLimit) {
|
||||
return min();
|
||||
await min();
|
||||
} else if (hasLongTermLimit) {
|
||||
return max();
|
||||
await max();
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue