douyin-release-gate / verify (push) Failing after 18m54s
Add Douyin notification polling, event details, and manual multi-account private messaging. Refine environment memory settings, account operations, login collection recovery, and message UI; update tests and documentation.
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
creator "git.ipao.vip/rogee/creator-hub/internal/creator"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type eventCoverFiles interface {
|
|
GetPlatformWorkCover(string, string) (string, error)
|
|
SavePlatformWorkCover(string, string, string, []byte) error
|
|
}
|
|
|
|
// Cover failures are per-event results: preserve the notification, expose the
|
|
// failure on its cover, and retry when the platform returns the notice again.
|
|
func cacheListenerWorkCovers(ctx context.Context, files eventCoverFiles, fetch func(context.Context, string) (string, []byte, error), items []creator.ListenerDelivery) {
|
|
for i := range items {
|
|
n := items[i].Notice
|
|
if n == nil || n.WorkID == "" || n.WorkAuthorUID == "" || n.WorkCoverURL == "" {
|
|
continue
|
|
}
|
|
_, err := files.GetPlatformWorkCover(n.WorkAuthorUID, n.WorkID)
|
|
if errors.Is(err, creator.ErrNotFound) {
|
|
var contentType string
|
|
var data []byte
|
|
contentType, data, err = fetch(ctx, n.WorkCoverURL)
|
|
if err == nil {
|
|
err = files.SavePlatformWorkCover(n.WorkAuthorUID, n.WorkID, contentType, data)
|
|
}
|
|
}
|
|
n.WorkCoverError = ""
|
|
if err != nil {
|
|
n.WorkCoverError = err.Error()
|
|
logrus.WithError(err).WithFields(logrus.Fields{"event_key": n.EventKey, "work_key": n.WorkID, "author_uid": n.WorkAuthorUID}).Error("notification cover cache failed")
|
|
}
|
|
}
|
|
}
|