fix: usage bug

This commit is contained in:
KernelDeimos
2024-11-19 11:08:54 -05:00
parent 7e7234b2f3
commit 0fd3b1e611
2 changed files with 8 additions and 2 deletions
@@ -320,10 +320,15 @@ class DriverService extends BaseService {
{
name: 'enforce monthly usage limit',
on_call: async args => {
// Typo-Tolerance
if ( effective_policy['monthy-limit'] ) {
effective_policy['monthly-limit'] = effective_policy['monthy-limit'];
}
if ( ! effective_policy?.['monthly-limit'] ) return args;
const svc_monthlyUsage = services.get('monthly-usage');
const count = await svc_monthlyUsage.check_2(
actor, method_key
actor, method_key, 0
);
if ( count >= effective_policy['monthly-limit'] ) {
throw APIError.create('monthly_limit_exceeded', null, {
@@ -63,7 +63,8 @@ class MonthlyUsageService extends BaseService {
}
async check_2 (actor, key) {
async check_2 (actor, key, ver) {
// TODO: get 'ver' working here for future updates
key = `${actor.uid}:${key}`;
if ( actor.type instanceof UserActorType ) {
return await this._user_check_2(actor, key);