feat: add configuration for whatsapp service
parent
d612b6725a
commit
82e7879969
|
@ -0,0 +1,25 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddNotificationConfigToItemQueue1734717058658
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddNotificationConfigToItemQueue1734717058658';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_queues" ADD "use_notification" boolean NOT NULL DEFAULT true`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_queues" ADD "requiring_notification" boolean NOT NULL DEFAULT false`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_queues" DROP COLUMN "requiring_notification"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_queues" DROP COLUMN "use_notification"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddLastNotificationToQueue1734718462106
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddLastNotificationToQueue1734718462106';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "queues" ADD "last_notification" bigint NULL`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "queues" DROP COLUMN "last_notification"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -33,4 +33,10 @@ export class ItemQueueModel
|
|||
onUpdate: 'CASCADE',
|
||||
})
|
||||
items: ItemModel[];
|
||||
|
||||
@Column('boolean', { default: true })
|
||||
use_notification: boolean;
|
||||
|
||||
@Column('boolean', { default: false })
|
||||
requiring_notification: boolean;
|
||||
}
|
||||
|
|
|
@ -9,4 +9,6 @@ export interface ItemQueueEntity extends BaseStatusEntity {
|
|||
max_peak_level: number;
|
||||
call_preparation: number;
|
||||
items: ItemEntity[];
|
||||
use_notification?: boolean;
|
||||
requiring_notification?: boolean;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ export class DetailItemQueueManager extends BaseDetailManager<ItemQueueEntity> {
|
|||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.max_peak_level`,
|
||||
`${this.tableName}.call_preparation`,
|
||||
`${this.tableName}.use_notification`,
|
||||
`${this.tableName}.requiring_notification`,
|
||||
|
||||
`items.id`,
|
||||
`items.created_at`,
|
||||
|
|
|
@ -41,6 +41,8 @@ export class IndexItemQueueManager extends BaseIndexManager<ItemQueueEntity> {
|
|||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.max_peak_level`,
|
||||
`${this.tableName}.call_preparation`,
|
||||
`${this.tableName}.use_notification`,
|
||||
`${this.tableName}.requiring_notification`,
|
||||
|
||||
`items.id`,
|
||||
`items.created_at`,
|
||||
|
|
|
@ -115,6 +115,9 @@ export class QueueModel extends BaseModel<Queue> implements Queue {
|
|||
@Column({ type: 'bigint' })
|
||||
time: number;
|
||||
|
||||
@Column({ type: 'bigint', nullable: true })
|
||||
last_notification: number;
|
||||
|
||||
@Column({ type: 'bigint' })
|
||||
call_time: number;
|
||||
|
||||
|
|
|
@ -9,3 +9,16 @@ export function toTime(timestamp: number): string {
|
|||
minutes < 10 ? '0' : ''
|
||||
}${minutes}`;
|
||||
}
|
||||
|
||||
export function phoneNumberOnly(phone: string): string {
|
||||
return phone.replace(/[^0-9]/g, '');
|
||||
}
|
||||
|
||||
export function timeIsBefore(
|
||||
currentTime: number,
|
||||
time: number,
|
||||
diff = 15,
|
||||
): boolean {
|
||||
const diffInMilliseconds = diff * 60 * 1000;
|
||||
return time < currentTime + diffInMilliseconds;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue