package threads_account

import (
	"context"

	cfentity "haixun-backend/internal/model/content_formula/domain/entity"
	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"
)

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

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

func (l *ImportOwnPostToContentFormulaLogic) ImportOwnPostToContentFormula(req *types.ImportOwnPostFormulaHandlerReq) (*types.AnalyzeContentFormulaData, error) {
	analyze := NewAnalyzeContentFormulaLogic(l.ctx, l.svcCtx)
	return analyze.AnalyzeContentFormula(&types.AnalyzeContentFormulaHandlerReq{
		ThreadsAccountPath: types.ThreadsAccountPath{ID: req.ID},
		AnalyzeContentFormulaReq: types.AnalyzeContentFormulaReq{
			SourceType: cfentity.SourceOwnPost,
			MediaID:    req.MediaID,
			SaveLabel:  req.Label,
		},
	})
}
