fix gateway share resolution and competitor identity
This commit is contained in:
@@ -1441,7 +1441,7 @@ func (browser creatorGatewayBrowser) Get(ctx context.Context, target string) (do
|
||||
func (browser creatorGatewayBrowser) Resolve(ctx context.Context, target string) (string, error) {
|
||||
payload := gatewayGenerationPayload(browser.environment)
|
||||
payload["url"] = target
|
||||
status, body, err := gatewayCall(ctx, browser.gateway, http.MethodPost, "/v1/browsers/"+url.PathEscape(browser.environment.Alias)+"/douyin/resolve", payload, 30*time.Second)
|
||||
status, body, err := gatewayCall(ctx, browser.gateway, http.MethodPost, "/v1/browsers/"+url.PathEscape(browser.environment.Alias)+"/douyin/resolve", payload, gatewayBrowserOperationTimeout)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -1535,6 +1535,7 @@ type competitorSharePreview struct {
|
||||
AccountID string `json:"account_id"`
|
||||
Platform string `json:"platform"`
|
||||
PlatformAccountKey string `json:"platform_account_key"`
|
||||
UniqueID string `json:"unique_id,omitempty"`
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarURL string `json:"avatar_url,omitempty"`
|
||||
HomepageURL string `json:"homepage_url"`
|
||||
@@ -1545,6 +1546,7 @@ func (preview competitorSharePreview) input() creator.CompetitorInput {
|
||||
return creator.CompetitorInput{
|
||||
Platform: preview.Platform,
|
||||
PlatformAccountKey: preview.PlatformAccountKey,
|
||||
UniqueID: preview.UniqueID,
|
||||
Nickname: preview.Nickname,
|
||||
AvatarURL: preview.AvatarURL,
|
||||
HomepageURL: preview.HomepageURL,
|
||||
@@ -1720,13 +1722,21 @@ func previewDouyinCompetitorShare(ctx context.Context, store *creator.Store, pha
|
||||
if err != nil {
|
||||
return competitorSharePreview{}, err
|
||||
}
|
||||
target, err := (douyin.CreatorCollector{Browser: browser}).ResolveWork(ctx, workKey)
|
||||
if err != nil {
|
||||
return competitorSharePreview{}, fmt.Errorf("%w: target identity verification failed: %v", creator.ErrConflict, err)
|
||||
var target douyin.TargetProfile
|
||||
page, pageErr := browser.Get(ctx, canonicalURL)
|
||||
if pageErr == nil && page.Status >= http.StatusOK && page.Status < http.StatusMultipleChoices {
|
||||
target, _ = douyin.ParseShareTargetHTML(page.Body, workKey)
|
||||
}
|
||||
if target.SecUID == "" {
|
||||
target, err = (douyin.CreatorCollector{Browser: browser}).ResolveWork(ctx, workKey)
|
||||
if err != nil {
|
||||
return competitorSharePreview{}, fmt.Errorf("%w: target identity verification failed: %v", creator.ErrConflict, err)
|
||||
}
|
||||
}
|
||||
return competitorSharePreview{
|
||||
Platform: creator.PlatformDouyin,
|
||||
PlatformAccountKey: target.SecUID,
|
||||
UniqueID: target.UniqueID,
|
||||
Nickname: target.Nickname,
|
||||
AvatarURL: target.AvatarURL,
|
||||
HomepageURL: "https://www.douyin.com/user/" + target.SecUID,
|
||||
@@ -1826,6 +1836,7 @@ func previewDouyinCompetitor(ctx context.Context, store *creator.Store, phaseASt
|
||||
"account_id": accountID,
|
||||
"platform": creator.PlatformDouyin,
|
||||
"platform_account_key": target.SecUID,
|
||||
"unique_id": target.UniqueID,
|
||||
"nickname": target.Nickname,
|
||||
"avatar_url": target.AvatarURL,
|
||||
"homepage_url": "https://www.douyin.com/user/" + target.SecUID,
|
||||
|
||||
@@ -66,10 +66,11 @@ type runtimeCleanupStore interface {
|
||||
}
|
||||
|
||||
const (
|
||||
gatewayLongTimeout = 11 * time.Minute // 覆盖网关侧最长 10 分钟的镜像拉取
|
||||
gatewayReconcileDelay = 100 * time.Millisecond
|
||||
gatewayReconcileAttempts = 10
|
||||
missingRuntimeID = "runtime-not-found"
|
||||
gatewayLongTimeout = 11 * time.Minute // 覆盖网关侧最长 10 分钟的镜像拉取
|
||||
gatewayBrowserOperationTimeout = 90 * time.Second
|
||||
gatewayReconcileDelay = 100 * time.Millisecond
|
||||
gatewayReconcileAttempts = 10
|
||||
missingRuntimeID = "runtime-not-found"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user