package threads_account

import (
	"context"

	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"
)

type GetPublishQueueItemLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetPublishQueueItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublishQueueItemLogic {
	return &GetPublishQueueItemLogic{ctx: ctx, svcCtx: svcCtx}
}

func (l *GetPublishQueueItemLogic) GetPublishQueueItem(req *types.PublishQueueItemPath) (*types.PublishQueueItemData, error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	result, err := l.svcCtx.PublishQueue.Get(l.ctx, tenantID, uid, req.ID, req.QID)
	if err != nil {
		return nil, err
	}
	return toPublishQueueItemData(result), nil
}
