// post.service.ts
import {Injectable} from '@nestjs/common';
import {SQS_QUEUES_NAME, SqsService} from './sqs.service';


@Injectable()
export class SqsPostService {
    constructor(private readonly sqs: SqsService) {
    }

    async sendMessage(username: string, data) {
        console.log(`SqsPostService -> sendMessage ${username} `);
        switch (username) {
            case 'realflashkaze': {
                return this.postFlashKaze(data)
                break;
            }
            case 'echcomvuive': {
                return this.postEchCom(data)
                break;
            }
        }
    }

    async postFlashKaze(data: any): Promise<any> {
        console.log(`SqsPostService_postFlashKaze`)
        return this.sqs.enqueue(
            SQS_QUEUES_NAME.REALFLASHKAZE!,
            data,
            {
                jobId: `acc1-${Date.now()}`,
                delaySeconds: Math.floor(Math.random() * 30),
            },
        );
    }

    async postEchCom(data: any) {
        console.log(`SqsPostService_postEchCom`)

        await this.sqs.enqueue(
            SQS_QUEUES_NAME.ECHCOMVUIVE!,
            data,
            {
                jobId: `acc2-${Date.now()}`,
                delaySeconds: Math.floor(Math.random() * 30),
            },
        );
    }
}
