fix: issues
This commit is contained in:
@@ -145,14 +145,26 @@ func (w *PostVideoExtractAudioJobWorker) Work(ctx context.Context, job *Job[Post
|
||||
return errors.Wrapf(err, "attach audio(%s) to post(%d) failed", audioPath, post.ID)
|
||||
}
|
||||
|
||||
if job.Args.Mark == "audio-preview" {
|
||||
post.Meta.WorkerMark = post.Meta.WorkerMark & 1 << 1
|
||||
} else if job.Args.Mark == "audio" {
|
||||
post.Meta.WorkerMark = post.Meta.WorkerMark & 1 << 2
|
||||
// 检查是否可发布
|
||||
post, err = w.postSvc.GetPostByID(ctx, job.Args.PostID)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "get post(%d) failed", job.Args.PostID)
|
||||
}
|
||||
|
||||
if err := w.postSvc.UpdateMeta(ctx, job.Args.TenantID, job.Args.UserID, post.ID, post.Meta); err != nil {
|
||||
return errors.Wrapf(err, "update post(%d) meta failed", post.ID)
|
||||
marks := lo.Map(post.Assets.Data, func(asset fields.MediaAsset, _ int) string {
|
||||
if asset.Mark != nil {
|
||||
return *asset.Mark
|
||||
}
|
||||
return ""
|
||||
})
|
||||
if items := lo.Intersect([]string{"audio-preview", "video-preview", "video", "audio"}, marks); len(items) == 4 {
|
||||
if err := w.postSvc.UpdateStatus(ctx, job.Args.TenantID, job.Args.UserID, post.ID, fields.PostStatusVerified); err != nil {
|
||||
return errors.Wrapf(err, "update post(%d) status failed", post.ID)
|
||||
}
|
||||
|
||||
if err := w.postSvc.UpdateStage(ctx, job.Args.TenantID, job.Args.UserID, post.ID, fields.PostStageCompleted); err != nil {
|
||||
return errors.Wrapf(err, "update post(%d) state failed", post.ID)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user