package threads_account

import (
	"context"

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

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

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

func (l *ListThreadsPublishHealthLogic) ListThreadsPublishHealth(req *types.ListThreadsPublishHealthHandlerReq) (*types.ThreadsPublishHealthData, error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	result, err := l.svcCtx.PublishQueue.ListPublishHealth(l.ctx, tenantID, uid, req.ID, req.Page, req.PageSize)
	if err != nil {
		return nil, err
	}
	return toPublishHealthData(result), nil
}
