mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-22 13:15:49 +00:00
fix: usage bug
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user