package service

import (
	"context"

	filemanager "wucher/internal/domain/file_manager"
	"wucher/internal/queue"
)

type fileProcessingQueueAdapter struct {
	producer queue.FileProcessingJobProducer
}

func (a fileProcessingQueueAdapter) Enqueue(ctx context.Context, job filemanager.FileProcessingJob) error {
	return a.producer.Enqueue(ctx, queue.FileProcessingJob{
		JobID:      job.JobID,
		FileUUID:   job.FileUUID,
		Bucket:     job.Bucket,
		ObjectKey:  job.ObjectKey,
		UploadedBy: job.UploadedBy,
		MimeType:   job.MimeType,
		SizeBytes:  job.SizeBytes,
		TraceID:    job.TraceID,
		RequestID:  job.RequestID,
	})
}

func AdaptFileProcessingQueue(producer queue.FileProcessingJobProducer) filemanager.FileProcessingQueue {
	if producer == nil {
		return nil
	}
	return fileProcessingQueueAdapter{producer: producer}
}
