Compare commits

..

No commits in common. "development" and "1.4.5-alpha.1" have entirely different histories.

7 changed files with 16 additions and 91 deletions

View File

@ -73,14 +73,13 @@ export class LoginAdminQueueManager extends BaseCustomManager<UserEntity> {
message: `Akun anda sudah login di item "${hasLoginAsQueue?.item_name}"`,
error: 'Unauthorized',
});
} else if (itemLogin && itemLogin.user_id !== this.userLogin.id) {
throw new UnauthorizedException({
statusCode: HttpStatus.UNAUTHORIZED,
message: `"${userLoginItem.name}" masih login sebagai admin antrian `,
error: 'Unauthorized',
});
}
// else if (itemLogin && itemLogin.user_id !== this.userLogin.id) {
// throw new UnauthorizedException({
// statusCode: HttpStatus.UNAUTHORIZED,
// message: `"${userLoginItem.name}" masih login sebagai admin antrian `,
// error: 'Unauthorized',
// });
// }
// * Disini untuk isi token
const tokenData = {

View File

@ -19,7 +19,6 @@ export class CouchService {
}
async onModuleInit() {
// return;
const nano = this.nanoInstance;
for (const database of DatabaseListen) {
const db = nano.db.use(database);
@ -96,41 +95,4 @@ export class CouchService {
return null;
}
}
getUnixTimestampLast7Days() {
const date = new Date();
date.setDate(date.getDate() - 4);
date.setHours(0, 0, 0, 0);
return date.getTime();
}
public async clearTransactions() {
const nano = this.nanoInstance;
const transaction = nano.use('transaction');
const expiredDate = this.getUnixTimestampLast7Days();
const selectorPayment = {
created_at: {
$lt: expiredDate,
},
};
const transactions = await transaction.find({
selector: selectorPayment,
fields: ['_id', '_rev'],
limit: 100000,
});
const { docs } = transactions;
console.log(docs.length);
const deletedDocs = {
docs: docs.map((doc) => ({
_id: doc._id,
_rev: doc._rev,
_deleted: true,
})),
};
await transaction.bulk(deletedDocs);
}
}

View File

@ -5,17 +5,13 @@ import { Public } from 'src/core/guards';
import * as Nano from 'nano';
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
import { ConfigService } from '@nestjs/config';
import { CouchService } from '../data/services/couch.service';
@ApiTags(`couch`)
@Controller('v1/couch')
@Public()
@Injectable()
export class CouchDataController {
constructor(
private configService: ConfigService,
private couchService: CouchService,
) {}
constructor(private configService: ConfigService) {}
get nanoInstance() {
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
@ -68,11 +64,4 @@ export class CouchDataController {
// return people.get();
} catch (error) {}
}
@Public(true)
@Get('clear-transactions')
async clearTransactions(): Promise<string> {
await this.couchService.clearTransactions();
return 'OK';
}
}

View File

@ -1,10 +1,4 @@
import {
Controller,
Get,
Param,
Query,
UnauthorizedException,
} from '@nestjs/common';
import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterItemQueueDto } from './dto/filter-item-queue.dto';
import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
@ -13,7 +7,6 @@ import { ItemQueueReadOrchestrator } from '../domain/usecases/item-queue-read.or
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { Public } from 'src/core/guards';
import { validate as isValidUUID } from 'uuid';
@ApiTags(`${MODULE_NAME.ITEM_QUEUE.split('-').join(' ')} - read`)
@Controller(`v1/${MODULE_NAME.ITEM_QUEUE}`)
@ -51,7 +44,6 @@ export class ItemQueueReadController {
@Get('display/:id')
@Public(true)
async detailPublic(@Param('id') id: string): Promise<ItemQueueEntity> {
if (!isValidUUID(id)) throw new UnauthorizedException('id is required');
return await this.orchestrator.detail(id);
}
}

View File

@ -87,10 +87,7 @@ export class QueueAdminOrchestrator {
// },
// ]);
if (
queueTicket.item.ticket.phone != null &&
queueTicket.last_notification < currentTime - call_preparation
) {
if (queueTicket.last_notification < currentTime - call_preparation) {
await notification.queueProcess(payload);
this.service.updateLastNotification(queueId, currentTime);
}

View File

@ -153,9 +153,6 @@ export class GenerateQueueManager {
registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
await registerQueueManager.execute();
const result = await registerQueueManager.getResult();
result.time = null;
return result;
return registerQueueManager.getResult();
}
}

View File

@ -12,7 +12,6 @@ import {
} from './whatsapp.constant';
import axios from 'axios';
import { Logger } from '@nestjs/common';
import { apm } from 'src/core/apm';
export class WhatsappService {
async sendMessage(data) {
@ -26,14 +25,8 @@ export class WhatsappService {
data: data,
};
try {
const response = await axios(config);
return response.data;
} catch (error) {
Logger.error(error);
apm?.captureError(error);
return null;
}
const response = await axios(config);
return response.data;
}
async queueRegister(data: WhatsappQueue) {
@ -98,11 +91,8 @@ export class WhatsappService {
},
};
const response = await this.sendMessage(payload);
if (response)
Logger.log(
`Notification register for ${data.code} send to ${data.phone}`,
);
await this.sendMessage(payload);
Logger.log(`Notification register for ${data.code} send to ${data.phone}`);
}
async queueProcess(data: WhatsappQueue) {
@ -162,8 +152,7 @@ export class WhatsappService {
},
};
const response = await this.sendMessage(payload);
if (response)
Logger.log(`Notification process for ${data.code} send to ${data.phone}`);
await this.sendMessage(payload);
Logger.log(`Notification process for ${data.code} send to ${data.phone}`);
}
}