File size: 1,246 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Injectable, UnprocessableEntityException } from '@nestjs/common';
import { IAppsService } from '@waha/apps/app_sdk/services/IAppsService';
import { DataStore } from '@waha/core/abc/DataStore';
import { SessionManager } from '@waha/core/abc/manager.abc';
import { WhatsappSession } from '@waha/core/abc/session.abc';
import { Knex } from 'knex';

import { App } from '../dto/app.dto';

class AppsIsDisabledError extends UnprocessableEntityException {
  constructor() {
    super(
      "Apps are disabled. Enable it by setting 'WAHA_APPS_ENABLED=True' environment variable.",
    );
  }
}

@Injectable()
export class AppsDisabledService implements IAppsService {
  async list(manager: SessionManager, session: string): Promise<App[]> {
    throw new AppsIsDisabledError();
  }

  async create(manager: SessionManager, app: App): Promise<App> {
    throw new AppsIsDisabledError();
  }

  async update(manager: SessionManager, app: App) {
    throw new AppsIsDisabledError();
  }

  async delete(manager: SessionManager, appId: string) {
    throw new AppsIsDisabledError();
  }

  migrate(knex: Knex<any, any[]>): Promise<void> {
    return;
  }

  async beforeSessionStart(session: WhatsappSession, store: DataStore) {
    return;
  }
}