feat: scope articles by brand
This commit is contained in:
@@ -122,6 +122,10 @@ func (s *ArticleImitationService) runtimeConfig() generationRuntimeConfig {
|
||||
|
||||
func (s *ArticleImitationService) Generate(ctx context.Context, req GenerateImitationRequest) (*GenerateImitationResponse, error) {
|
||||
actor := auth.MustActor(ctx)
|
||||
brandID, err := requireCurrentBrandID(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.llm.Validate(); err != nil {
|
||||
return nil, response.ErrServiceUnavailable(50311, "llm_unavailable", err.Error())
|
||||
}
|
||||
@@ -141,6 +145,7 @@ func (s *ArticleImitationService) Generate(ctx context.Context, req GenerateImit
|
||||
}
|
||||
|
||||
inputParams := buildImitationInputParams(sourceURL, req)
|
||||
inputParams["brand_id"] = brandID
|
||||
inputJSON, _ := json.Marshal(inputParams)
|
||||
initialTitle := buildImitationInitialTitle(req.SourceTitle)
|
||||
wizardStateJSON, _ := json.Marshal(map[string]interface{}{
|
||||
@@ -192,10 +197,10 @@ func (s *ArticleImitationService) Generate(ctx context.Context, req GenerateImit
|
||||
|
||||
var articleID int64
|
||||
err = tx.QueryRow(ctx, `
|
||||
INSERT INTO articles (tenant_id, source_type, generate_status, publish_status, wizard_state_json)
|
||||
VALUES ($1, $2, 'generating', 'unpublished', $3)
|
||||
INSERT INTO articles (tenant_id, brand_id, source_type, generate_status, publish_status, wizard_state_json)
|
||||
VALUES ($1, $2, $3, 'generating', 'unpublished', $4)
|
||||
RETURNING id
|
||||
`, actor.TenantID, articleImitationSourceType, wizardStateJSON).Scan(&articleID)
|
||||
`, actor.TenantID, brandID, articleImitationSourceType, wizardStateJSON).Scan(&articleID)
|
||||
if err != nil {
|
||||
return nil, response.ErrInternal(50012, "create_failed", "failed to create imitation article")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user