package job

import (
	"strings"

	"haixun-backend/internal/model/job/domain/entity"
)

func runActorFromPayload(payload map[string]any, run *entity.Run) (tenantID, ownerUID string) {
	tenantID = stringField(payload, "tenant_id")
	ownerUID = stringField(payload, "owner_uid")
	if run == nil {
		return tenantID, ownerUID
	}
	if tenantID == "" {
		tenantID = strings.TrimSpace(run.TenantID)
	}
	if ownerUID == "" {
		ownerUID = strings.TrimSpace(run.OwnerUID)
	}
	return tenantID, ownerUID
}
