Merge pull request 'conflict' (#589) from conflict into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/589
This commit is contained in:
commit
f77c42e45b
|
@ -2,7 +2,6 @@ package controller
|
|||
|
||||
import (
|
||||
video_moderation_proto "service/api/proto/video_moderation/proto"
|
||||
"service/app/mix/service"
|
||||
"service/bizcommon/util"
|
||||
videomoderation "service/library/contentaudit/video_moderation"
|
||||
"service/library/logger"
|
||||
|
@ -19,19 +18,11 @@ func VideoModerationCallback(ctx *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
batchId, isBatchFinished, err := videomoderation.HandleVideoModerationContent(req.Content)
|
||||
err = videomoderation.HandleVideoModerationContent(req.Content)
|
||||
if err != nil {
|
||||
logger.Error("HandleVideoModerationContent fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
return
|
||||
}
|
||||
|
||||
// 同步批次视频审核结果
|
||||
if isBatchFinished {
|
||||
err = service.DefaultService.SyncVideoModerationTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
logger.Error("ERROR : batchId : %v, video moderation tasks of this batchId have failed to syncronize, err :%v", batchId, err)
|
||||
}
|
||||
}
|
||||
|
||||
ctx.String(200, "success")
|
||||
}
|
||||
|
|
|
@ -3441,27 +3441,6 @@ func (m *Mongo) GetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_taskp
|
|||
return list, err
|
||||
}
|
||||
|
||||
func (m *Mongo) GetMomentAuditTaskListWaitingForManuallyReview(ctx *gin.Context, batchId string) ([]*dbstruct.MomentAuditTask, error) {
|
||||
list := make([]*dbstruct.MomentAuditTask, 0)
|
||||
col := m.getColMomentAuditTask()
|
||||
query := qmgo.M{
|
||||
"manually_review_status": consts.MomentManuallyReview_Waiting,
|
||||
"image_audit_task_status": qmgo.M{
|
||||
"$ne": consts.ImageAudit_Created,
|
||||
},
|
||||
"text_audit_task_status": qmgo.M{
|
||||
"$ne": consts.TextAudit_Created,
|
||||
},
|
||||
"del_flag": 0,
|
||||
}
|
||||
err := col.Find(ctx, query).All(&list)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
err = nil
|
||||
return list, err
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (m *Mongo) UpdateMomentAuditTaskByImageAuditTaskIds(ctx *gin.Context, moment_audit_task *dbstruct.MomentAuditTask, ids []string) error {
|
||||
col := m.getColMomentAuditTask()
|
||||
set := util.EntityToM(moment_audit_task)
|
||||
|
@ -3511,6 +3490,90 @@ func (m *Mongo) UpdateMomentAuditTaskByMomentIdsAndStatus(ctx *gin.Context, mome
|
|||
return err
|
||||
}
|
||||
|
||||
func (m *Mongo) TryToFinishyImageAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.ImageAuditTask, opinion string) (*dbstruct.MomentAuditTask, error) {
|
||||
col := m.getColMomentAuditTask()
|
||||
filter := qmgo.M{
|
||||
"image_audit_task_id": task.GetId(),
|
||||
"manually_review_status": consts.MomentManuallyReview_Waiting,
|
||||
"del_flag": 0,
|
||||
}
|
||||
change := qmgo.Change{
|
||||
Update: qmgo.M{
|
||||
"$set": qmgo.M{
|
||||
"image_audit_task_status": task.GetStatus(),
|
||||
"image_audit_opinion": opinion,
|
||||
}},
|
||||
Upsert: false,
|
||||
ReturnNew: true,
|
||||
}
|
||||
instance := dbstruct.MomentAuditTask{}
|
||||
err := col.Find(ctx, filter).Apply(change, &instance)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("change error : %v", err)
|
||||
return nil, err
|
||||
}
|
||||
return &instance, nil
|
||||
}
|
||||
|
||||
func (m *Mongo) TryToFinishTextAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.TextAuditTask, opinion string) (*dbstruct.MomentAuditTask, error) {
|
||||
col := m.getColMomentAuditTask()
|
||||
filter := qmgo.M{
|
||||
"text_audit_task_id": task.GetId(),
|
||||
"manually_review_status": consts.MomentManuallyReview_Waiting,
|
||||
"del_flag": 0,
|
||||
}
|
||||
change := qmgo.Change{
|
||||
Update: qmgo.M{
|
||||
"$set": qmgo.M{
|
||||
"text_audit_task_status": task.GetStatus(),
|
||||
"text_audit_opinion": opinion,
|
||||
}},
|
||||
Upsert: false,
|
||||
ReturnNew: true,
|
||||
}
|
||||
instance := dbstruct.MomentAuditTask{}
|
||||
err := col.Find(ctx, filter).Apply(change, &instance)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("change error : %v", err)
|
||||
return nil, err
|
||||
}
|
||||
return &instance, nil
|
||||
}
|
||||
|
||||
func (m *Mongo) TryToFinishVideoModerationTaskOfMoment(ctx *gin.Context, task *dbstruct.VideoModerationTask, opinion string) (*dbstruct.MomentAuditTask, error) {
|
||||
col := m.getColMomentAuditTask()
|
||||
filter := qmgo.M{
|
||||
"image_audit_task_id": task.GetId(),
|
||||
"manually_review_status": consts.MomentManuallyReview_Waiting,
|
||||
"del_flag": 0,
|
||||
}
|
||||
change := qmgo.Change{
|
||||
Update: qmgo.M{
|
||||
"$set": qmgo.M{
|
||||
"image_audit_task_status": task.GetStatus(),
|
||||
"image_audit_opinion": opinion,
|
||||
}},
|
||||
Upsert: false,
|
||||
ReturnNew: true,
|
||||
}
|
||||
instance := dbstruct.MomentAuditTask{}
|
||||
err := col.Find(ctx, filter).Apply(change, &instance)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("change error : %v", err)
|
||||
return nil, err
|
||||
}
|
||||
return &instance, nil
|
||||
}
|
||||
|
||||
// 联系客服对话表相关
|
||||
func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error {
|
||||
col := m.getColContactCustomerServiceSession()
|
||||
|
|
|
@ -138,16 +138,24 @@ func (handler *ImageAuditTaskResultHandler) generateStreamerAlbumUpdateFunc() {
|
|||
func (handler *ImageAuditTaskResultHandler) generateMomentMediaComponentUpdateFunc() {
|
||||
handler.imageAuditTaskUpdateFuncGeneratorMap["moment|moment|media_component"] = func(ctx *gin.Context, task *dbstruct.ImageAuditTask, option int) func() error {
|
||||
return func() error {
|
||||
|
||||
// 20240703:同步动态审核表触发人审的逻辑改到handler实现
|
||||
// moment_audit_task有image_audit_task_id的索引,以该索引作为更新依据
|
||||
// image_audit_task有associative_table_id的内容,以该id去触发moment的更新
|
||||
// 通过逻辑只做恢复,不包含任何触发人审的操作
|
||||
|
||||
//20240403更新: 增加成功后处理的切面
|
||||
if option == consts.ImageAuditTaskUpdate_Success {
|
||||
return nil
|
||||
return tryToFinishImageAuditTaskOfMoment(ctx, task)
|
||||
}
|
||||
|
||||
if option == consts.ImageAuditTaskUpdate_Pass {
|
||||
return passMomentImageAuditTask(ctx, task)
|
||||
|
||||
} else {
|
||||
return rollbackMomentImageAuditTask(ctx, task)
|
||||
if err := rollbackMomentImageAuditTask(ctx, task); err != nil {
|
||||
return err
|
||||
}
|
||||
return tryToFinishImageAuditTaskOfMoment(ctx, task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +221,7 @@ func passMomentImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTask) (
|
|||
|
||||
if err := _DefaultMomentAuditTask.OpUpdateByImageAuditTaskIds(ctx, &dbstruct.MomentAuditTask{
|
||||
FinalMedia: task.AuditedMedia,
|
||||
}, []string{util.DerefString(task.Id)}); err != nil {
|
||||
}, []string{task.GetId()}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -245,7 +253,7 @@ func rollbackMomentImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTas
|
|||
|
||||
if err := _DefaultMomentAuditTask.OpUpdateByImageAuditTaskIds(ctx, &dbstruct.MomentAuditTask{
|
||||
FinalMedia: mediaComp,
|
||||
}, []string{util.DerefString(task.Id)}); err != nil {
|
||||
}, []string{task.GetId()}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -254,3 +262,24 @@ func rollbackMomentImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTas
|
|||
return _DefaultMoment.OpDelete(ctx, util.DerefInt64(task.AssociativeTableId))
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试完成审核
|
||||
func tryToFinishImageAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.ImageAuditTask) error {
|
||||
// 机审通过,尝试触发moment_audit_task的人审
|
||||
isFinished, err := _DefaultMomentAuditTask.TryToFinishImageAuditTask(ctx, task, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isFinished { // 机审完成,通知moment表机审已完成
|
||||
err = _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
|
||||
Moment: &dbstruct.Moment{
|
||||
Id: task.AssociativeTableId,
|
||||
Status: goproto.Int64(consts.Moment_ManuallyReviewing),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -64,16 +64,6 @@ func (p *MomentAuditTask) OpList(ctx *gin.Context, req *moment_audit_taskproto.O
|
|||
return list, nil
|
||||
}
|
||||
|
||||
// 查询所有应进入人工复审的帖子
|
||||
func (p *MomentAuditTask) OpListWaitingForManuallyReview(ctx *gin.Context, batchId string) ([]*dbstruct.MomentAuditTask, error) {
|
||||
list, err := p.store.GetMomentAuditTaskListWaitingForManuallyReview(ctx, batchId)
|
||||
if err != nil {
|
||||
logger.Error("GetMomentAuditTaskList fail, err: %v", err)
|
||||
return make([]*dbstruct.MomentAuditTask, 0), err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) OpUpdateByImageAuditTaskIds(ctx *gin.Context, moment_audit_task *dbstruct.MomentAuditTask, ids []string) error {
|
||||
err := p.store.UpdateMomentAuditTaskByImageAuditTaskIds(ctx, moment_audit_task, ids)
|
||||
if err != nil {
|
||||
|
@ -100,3 +90,42 @@ func (p *MomentAuditTask) OpUpdateByMomentIdsAndStatus(ctx *gin.Context, moment_
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) TryToFinishImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTask, opinion string) (isFinished bool, err error) {
|
||||
instance, err := p.store.TryToFinishyImageAuditTaskOfMoment(ctx, task, opinion)
|
||||
if err != nil {
|
||||
logger.Error("TryToFinishyImageAuditTaskOfMoment fail, err: %v", err)
|
||||
return false, err
|
||||
}
|
||||
if instance == nil {
|
||||
logger.Error("No moment audit task was found...")
|
||||
return false, nil
|
||||
}
|
||||
return instance.GetImageAuditTaskStatus() != consts.ImageAudit_Created && instance.GetTextAuditTaskStatus() != consts.TextAudit_Created, nil
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) TryToFinishTextAuditTask(ctx *gin.Context, task *dbstruct.TextAuditTask, opinion string) (isFinished bool, err error) {
|
||||
instance, err := p.store.TryToFinishTextAuditTaskOfMoment(ctx, task, opinion)
|
||||
if err != nil {
|
||||
logger.Error("TryToFinishTextAuditTaskOfMoment fail, err: %v", err)
|
||||
return false, err
|
||||
}
|
||||
if instance == nil {
|
||||
logger.Error("No moment audit task was found...")
|
||||
return false, nil
|
||||
}
|
||||
return instance.GetImageAuditTaskStatus() != consts.ImageAudit_Created && instance.GetTextAuditTaskStatus() != consts.TextAudit_Created, nil
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) TryToFinishVideoModerationTask(ctx *gin.Context, task *dbstruct.VideoModerationTask, opinion string) (isFinished bool, err error) {
|
||||
instance, err := p.store.TryToFinishVideoModerationTaskOfMoment(ctx, task, opinion)
|
||||
if err != nil {
|
||||
logger.Error("TryToFinishVideoModerationTaskOfMoment fail, err: %v", err)
|
||||
return false, err
|
||||
}
|
||||
if instance == nil {
|
||||
logger.Error("No moment audit task was found...")
|
||||
return false, nil
|
||||
}
|
||||
return instance.GetImageAuditTaskStatus() != consts.ImageAudit_Created && instance.GetTextAuditTaskStatus() != consts.TextAudit_Created, nil
|
||||
}
|
||||
|
|
|
@ -161,9 +161,14 @@ func (handler *TextAuditTaskResultHandler) generateStreamerAutoResponseMessageUp
|
|||
func (handler *TextAuditTaskResultHandler) generateMomentTextUpdateFunc() {
|
||||
handler.textAuditTaskUpdateFuncGeneratorMap["moment|moment|text"] = func(ctx *gin.Context, task *dbstruct.TextAuditTask, option int) func() error {
|
||||
return func() error {
|
||||
// 20240703:同步动态审核表触发人审的逻辑改到handler实现
|
||||
// moment_audit_task有text_audit_task_id的索引,以该索引作为更新依据
|
||||
// text_audit_task有associative_table_id的内容,以该id去触发moment的更新
|
||||
// 通过逻辑只做恢复,不包含任何触发人审的操作
|
||||
|
||||
//20240403更新: 增加成功后处理的切面
|
||||
if option == consts.TextAuditTaskUpdate_Success {
|
||||
return nil
|
||||
return tryToFinishTextAuditTaskOfMoment(ctx, task)
|
||||
}
|
||||
|
||||
momentId := task.AssociativeTableId
|
||||
|
@ -186,7 +191,8 @@ func (handler *TextAuditTaskResultHandler) generateMomentTextUpdateFunc() {
|
|||
}, []string{util.DerefString(task.Id)}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
return tryToFinishTextAuditTaskOfMoment(ctx, task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,3 +235,24 @@ func (handler *TextAuditTaskResultHandler) generateZoneMomentTextUpdateFunc() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试完成审核
|
||||
func tryToFinishTextAuditTaskOfMoment(ctx *gin.Context, task *dbstruct.TextAuditTask) error {
|
||||
// 机审通过,尝试触发moment_audit_task的人审
|
||||
isFinished, err := _DefaultMomentAuditTask.TryToFinishTextAuditTask(ctx, task, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isFinished { // 机审完成,通知moment表机审已完成
|
||||
err = _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
|
||||
Moment: &dbstruct.Moment{
|
||||
Id: task.AssociativeTableId,
|
||||
Status: goproto.Int64(consts.Moment_ManuallyReviewing),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -20,14 +20,12 @@ import (
|
|||
textauditproto "service/api/proto/textaudit/proto"
|
||||
textaudittaskproto "service/api/proto/textaudittask/proto"
|
||||
thumbsupproto "service/api/proto/thumbsup/proto"
|
||||
video_moderation_task_proto "service/api/proto/video_moderation_task/proto"
|
||||
zoneproto "service/api/proto/zone/proto"
|
||||
zone_collaborator_proto "service/api/proto/zone_collaborator/proto"
|
||||
zone_third_partner_proto "service/api/proto/zone_third_partner/proto"
|
||||
zonemomentproto "service/api/proto/zonemoment/proto"
|
||||
zonemomentthumbsupproto "service/api/proto/zonemomentthumbsup/proto"
|
||||
"service/apollostruct"
|
||||
"service/app/mix/dao"
|
||||
"service/bizcommon/util"
|
||||
"service/dbstruct"
|
||||
"service/library/apollo"
|
||||
|
@ -35,7 +33,6 @@ import (
|
|||
"service/library/mycrypto"
|
||||
"service/library/redis"
|
||||
"service/library/validator"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -418,125 +415,6 @@ func (s *Service) utilFillTextAuditTaskVO(ctx *gin.Context, vo *textaudittaskpro
|
|||
return nil
|
||||
}
|
||||
|
||||
// 同步图像审核结果
|
||||
func (s *Service) utilSyncImageAuditTaskResultByBatchId(ctx *gin.Context, batchId string) (err error) {
|
||||
// 查询得到该批次所有有关动态的图像审核任务
|
||||
imageaudittasks, err := _DefaultImageAuditTask.OpList(ctx, &imageaudittaskproto.OpListReq{
|
||||
AssociativeDatabase: goproto.String(dao.DBMoment),
|
||||
AssociativeTableName: goproto.String(dao.COLMoment),
|
||||
AssociativeTableColumn: goproto.String("media_component"),
|
||||
BatchId: goproto.String(batchId),
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultImageAuditTask OpList fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 将有关动态的图像审核任务审核结果同步到动态审核表
|
||||
_map := make(map[int64][]string)
|
||||
for _, imageaudittask := range imageaudittasks {
|
||||
ids := _map[util.DerefInt64(imageaudittask.Status)]
|
||||
ids = append(ids, util.DerefString(imageaudittask.Id))
|
||||
_map[util.DerefInt64(imageaudittask.Status)] = ids
|
||||
}
|
||||
for status, ids := range _map {
|
||||
logger.Info("status: %v, ids: %v", status, ids)
|
||||
task := &dbstruct.MomentAuditTask{
|
||||
ImageAuditTaskStatus: goproto.Int64(status),
|
||||
}
|
||||
err = _DefaultMomentAuditTask.OpUpdateByImageAuditTaskIds(ctx, task, ids)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpUpdateByImageAuditTaskIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 同步本批次所有待人工复审的任务(通过,或机审失败)
|
||||
err = s.utilSyncWaitingForManuallyReviewMoment(ctx, batchId)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpUpdateByImageAuditTaskIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 同步文字审核结果
|
||||
func (s *Service) utilSyncTextAuditTaskResultByBatchId(ctx *gin.Context, batchId string) (err error) {
|
||||
// 查询得到该批次所有有关动态的文字审核任务
|
||||
textaudittasks, err := _DefaultTextAuditTask.OpList(ctx, &textaudittaskproto.OpListReq{
|
||||
AssociativeDatabase: goproto.String(dao.DBMoment),
|
||||
AssociativeTableName: goproto.String(dao.COLMoment),
|
||||
AssociativeTableColumn: goproto.String("text"),
|
||||
BatchId: goproto.String(batchId),
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultTextAuditTask OpList fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 将有关动态的图像审核任务审核结果同步到动态审核表
|
||||
_map := make(map[int64][]string)
|
||||
for _, textaudittask := range textaudittasks {
|
||||
ids := _map[util.DerefInt64(textaudittask.Status)]
|
||||
ids = append(ids, util.DerefString(textaudittask.Id))
|
||||
_map[util.DerefInt64(textaudittask.Status)] = ids
|
||||
}
|
||||
for status, ids := range _map {
|
||||
task := &dbstruct.MomentAuditTask{
|
||||
TextAuditTaskStatus: goproto.Int64(status),
|
||||
}
|
||||
err = _DefaultMomentAuditTask.OpUpdateByTextAuditTaskIds(ctx, task, ids)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpUpdateByTextAuditTaskIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 同步本批次所有待人工复审的任务(通过,或机审失败)
|
||||
err = s.utilSyncWaitingForManuallyReviewMoment(ctx, batchId)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpUpdateByImageAuditTaskIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 同步待人工审核的帖子
|
||||
func (s *Service) utilSyncWaitingForManuallyReviewMoment(ctx *gin.Context, batchId string) (err error) {
|
||||
// 查询本批次所有待人工复审的任务(通过,或机审失败)
|
||||
watingForManuallyReviewImageAuditTasks, err := _DefaultMomentAuditTask.OpListWaitingForManuallyReview(ctx, batchId)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpListWaitingForManuallyReview fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
// 统计该部分的动态id
|
||||
if len(watingForManuallyReviewImageAuditTasks) == 0 {
|
||||
return
|
||||
}
|
||||
momentIds := make([]int64, 0)
|
||||
for _, task := range watingForManuallyReviewImageAuditTasks {
|
||||
idInt, err := strconv.Atoi(util.DerefString(task.AssociativeTableId))
|
||||
if err != nil {
|
||||
logger.Error("strconv Atoi fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
momentIds = append(momentIds, int64(idInt))
|
||||
}
|
||||
// 将该部分动态的状态置为待人工审核
|
||||
err = _DefaultMoment.OpUpdateByIds(ctx, &momentproto.OpUpdateReq{
|
||||
Moment: &dbstruct.Moment{
|
||||
Status: goproto.Int64(consts.Moment_ManuallyReviewing),
|
||||
},
|
||||
}, momentIds)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMoment OpUpdateByIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 将联系客服消息转化为Text
|
||||
func (s *Service) utilStringifyContactCustomerServices(ctx *gin.Context, contactCustomerServices []*dbstruct.ContactCustomerService) (msg string, err error) {
|
||||
|
||||
|
@ -2156,46 +2034,3 @@ func (s *Service) utilSignHvyogoMessage(msg interfaces.HvyogoSignable) ([]byte,
|
|||
|
||||
return resultBytes, nil
|
||||
}
|
||||
|
||||
// 同步视频审核结果
|
||||
func (s *Service) SyncVideoModerationTaskResultByBatchId(ctx *gin.Context, batchId string) (err error) {
|
||||
// 查询得到该批次所有有关动态的视频审核任务
|
||||
videomoderationtasks, err := _DefaultVideoModerationTask.OpList(ctx, &video_moderation_task_proto.OpListReq{
|
||||
AssociativeDatabase: goproto.String(dao.DBMoment),
|
||||
AssociativeTableName: goproto.String(dao.COLMoment),
|
||||
AssociativeTableColumn: goproto.String("media_component"),
|
||||
BatchId: goproto.String(batchId),
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultVideoModerationTask OpList fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 将有关动态的视频审核任务审核结果同步到动态审核表
|
||||
_map := make(map[int64][]string)
|
||||
for _, videomoderationtask := range videomoderationtasks {
|
||||
ids := _map[videomoderationtask.GetStatus()]
|
||||
ids = append(ids, videomoderationtask.GetId())
|
||||
_map[videomoderationtask.GetStatus()] = ids
|
||||
}
|
||||
for status, ids := range _map {
|
||||
logger.Info("status: %v, ids: %v", status, ids)
|
||||
task := &dbstruct.MomentAuditTask{
|
||||
ImageAuditTaskStatus: goproto.Int64(status),
|
||||
}
|
||||
err = _DefaultMomentAuditTask.OpUpdateByImageAuditTaskIds(ctx, task, ids)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpUpdateByVideoModerationTaskIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 同步本批次所有待人工复审的任务(通过,或机审失败)
|
||||
err = s.utilSyncWaitingForManuallyReviewMoment(ctx, batchId)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultMomentAuditTask OpUpdateByVideoModerationTaskIds fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func (handler *VideoModerationTaskResultHandler) generateMomentMediaComponentUpd
|
|||
return func() error {
|
||||
//20240403更新: 增加成功后处理的切面
|
||||
if option == consts.ImageAuditTaskUpdate_Success {
|
||||
return nil
|
||||
return tryToFinishVideoModerationTaskOfMoment(ctx, task)
|
||||
}
|
||||
|
||||
if option == consts.ImageAuditTaskUpdate_Pass {
|
||||
|
@ -65,7 +65,7 @@ func (handler *VideoModerationTaskResultHandler) generateMomentMediaComponentUpd
|
|||
return nil
|
||||
|
||||
} else {
|
||||
return rollbackMomentVideoModerationTask(ctx, task)
|
||||
return tryToFinishVideoModerationTaskOfMoment(ctx, task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,15 +115,37 @@ func (handler *VideoModerationTaskResultHandler) generateZoneMomentMediaComponen
|
|||
}
|
||||
}
|
||||
|
||||
// 回退动态表视频
|
||||
func rollbackMomentVideoModerationTask(ctx *gin.Context, task *dbstruct.VideoModerationTask) (err error) {
|
||||
if err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
|
||||
Moment: &dbstruct.Moment{
|
||||
Id: task.AssociativeTableId,
|
||||
Status: goproto.Int64(consts.Moment_AuditRejected),
|
||||
},
|
||||
}); err != nil {
|
||||
// 尝试完成审核
|
||||
func tryToFinishVideoModerationTaskOfMoment(ctx *gin.Context, task *dbstruct.VideoModerationTask) error {
|
||||
|
||||
// 组装审核意见
|
||||
videoModerationOpinion := &strings.Builder{}
|
||||
if task.GetStatus() == consts.VideoModeration_ServiceFailed {
|
||||
videoModerationOpinion.WriteString("机审失败")
|
||||
} else {
|
||||
// 写入具体原因
|
||||
for i, pass := range task.AuditedMediaResults {
|
||||
if !pass {
|
||||
videoModerationOpinion.WriteString(fmt.Sprintf("视频%d:%s ", i+1, task.Description[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 机审完成,尝试触发moment_audit_task的人审
|
||||
isFinished, err := _DefaultMomentAuditTask.TryToFinishVideoModerationTask(ctx, task, videoModerationOpinion.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isFinished { // 机审完成,通知moment表机审已完成
|
||||
err = _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
|
||||
Moment: &dbstruct.Moment{
|
||||
Id: task.AssociativeTableId,
|
||||
Status: goproto.Int64(consts.Moment_ManuallyReviewing),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -210,11 +210,6 @@ func (s *CronService) ImageAuditBatch(ctx context.Context, param *xxl.RunReq) (m
|
|||
} else {
|
||||
handleMsg.WriteString(fmt.Sprintf("batchId : %v, image audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
|
||||
}
|
||||
// 同步图像审核结果
|
||||
err = DefaultService.utilSyncImageAuditTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
|
||||
}
|
||||
|
||||
logger.Info("Image audit batch ends...")
|
||||
return handleMsg.String()
|
||||
|
@ -232,11 +227,6 @@ func (s *CronService) ImageAuditBatchHis(ctx context.Context, param *xxl.RunReq)
|
|||
} else {
|
||||
handleMsg.WriteString(fmt.Sprintf("batchId : %v, image audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
|
||||
}
|
||||
// 同步图像审核结果
|
||||
err = DefaultService.utilSyncImageAuditTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
|
||||
}
|
||||
|
||||
logger.Info("Image audit batch ends...")
|
||||
return handleMsg.String()
|
||||
|
@ -259,11 +249,6 @@ func (s *CronService) TextAuditBatch(ctx context.Context, param *xxl.RunReq) (ms
|
|||
} else {
|
||||
handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
|
||||
}
|
||||
// 同步文字审核结果
|
||||
err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
|
||||
}
|
||||
|
||||
logger.Info("Text audit batch ends...")
|
||||
return handleMsg.String()
|
||||
|
@ -282,11 +267,6 @@ func (s *CronService) TextAuditBatchHis(ctx context.Context, param *xxl.RunReq)
|
|||
} else {
|
||||
handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
|
||||
}
|
||||
// 同步文字审核结果
|
||||
err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
|
||||
}
|
||||
|
||||
logger.Info("Text audit batch ends...")
|
||||
return handleMsg.String()
|
||||
|
@ -552,11 +532,6 @@ func (s *CronService) VideoModerationBatch(ctx context.Context, param *xxl.RunRe
|
|||
} else {
|
||||
handleMsg.WriteString(fmt.Sprintf("batchId : %v, video moderation tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
|
||||
}
|
||||
// 同步视频审核结果
|
||||
err = DefaultService.SyncVideoModerationTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, video moderation tasks of this batchId have failed to syncronize, err :%v", batchId, err))
|
||||
}
|
||||
|
||||
logger.Info("Video moderation batch ends...")
|
||||
return handleMsg.String()
|
||||
|
@ -574,11 +549,6 @@ func (s *CronService) VideoModerationBatchHis(ctx context.Context, param *xxl.Ru
|
|||
} else {
|
||||
handleMsg.WriteString(fmt.Sprintf("batchId : %v, video moderation tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
|
||||
}
|
||||
// 同步视频审核结果
|
||||
err = DefaultService.SyncVideoModerationTaskResultByBatchId(&gin.Context{}, batchId)
|
||||
if err != nil {
|
||||
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, video moderation tasks of this batchId have failed to syncronize, err :%v", batchId, err))
|
||||
}
|
||||
|
||||
logger.Info("Video moderation batch ends...")
|
||||
return handleMsg.String()
|
||||
|
|
|
@ -29,6 +29,27 @@ type ImageAuditTask struct {
|
|||
ImageAudits []*ImageAudit // 每个任务的结果
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) GetId() string {
|
||||
if p == nil || p.Id == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.Id
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) GetStatus() int64 {
|
||||
if p == nil || p.Id == nil {
|
||||
return 0
|
||||
}
|
||||
return *p.Status
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) GetAssociativeTableId() int64 {
|
||||
if p == nil || p.AssociativeTableId == nil {
|
||||
return 0
|
||||
}
|
||||
return *p.AssociativeTableId
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) IsEmpty() bool {
|
||||
if p == nil {
|
||||
return true
|
||||
|
|
|
@ -11,6 +11,8 @@ type MomentAuditTask struct {
|
|||
TextAuditTaskId *string `json:"text_audit_task_id" bson:"text_audit_task_id"` // 文字审核任务表id
|
||||
ImageAuditTaskStatus *int64 `json:"image_audit_task_status" bson:"image_audit_task_status"` // 图像审核任务审核状态
|
||||
TextAuditTaskStatus *int64 `json:"text_audit_task_status" bson:"text_audit_task_status"` // 文字审核任务审核状态
|
||||
ImageAuditOpinion *string `json:"image_audit_opinion" bson:"image_audit_opinion"` // 图像审核任务审核意见
|
||||
TextAuditOpinion *string `json:"text_audit_opinion" bson:"text_audit_opinion"` // 文字审核任务审核意见
|
||||
Status *int64 `json:"status" bson:"status"` // 是否已过期
|
||||
ManuallyReviewStatus *int64 `json:"manually_review_status" bson:"manually_review_status"` // 人工复审状态
|
||||
ManuallyReviewOperator *int64 `json:"manually_review_operator" bson:"manually_review_operator"` // 人工复审操作人
|
||||
|
@ -21,9 +23,30 @@ type MomentAuditTask struct {
|
|||
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) GetId() string {
|
||||
if p == nil || p.Id == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.Id
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) GetAssociativeTableId() string {
|
||||
if p == nil || p.AssociativeTableId == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.AssociativeTableId
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) GetImageAuditTaskStatus() int64 {
|
||||
if p == nil || p.ImageAuditTaskStatus == nil {
|
||||
return 0
|
||||
}
|
||||
return *p.ImageAuditTaskStatus
|
||||
}
|
||||
|
||||
func (p *MomentAuditTask) GetTextAuditTaskStatus() int64 {
|
||||
if p == nil || p.TextAuditTaskStatus == nil {
|
||||
return 0
|
||||
}
|
||||
return *p.TextAuditTaskStatus
|
||||
}
|
||||
|
|
|
@ -25,6 +25,27 @@ type TextAuditTask struct {
|
|||
TextAudit *TextAudit // 任务的结果
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) GetId() string {
|
||||
if p == nil || p.Id == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.Id
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) GetStatus() int64 {
|
||||
if p == nil || p.Id == nil {
|
||||
return 0
|
||||
}
|
||||
return *p.Status
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) GetAssociativeTableId() int64 {
|
||||
if p == nil || p.AssociativeTableId == nil {
|
||||
return 0
|
||||
}
|
||||
return *p.AssociativeTableId
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) IsEmpty() bool {
|
||||
if p == nil {
|
||||
return true
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
goproto "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func HandleVideoModerationContent(content string) (batchId string, isBatchFinished bool, err error) {
|
||||
func HandleVideoModerationContent(content string) (err error) {
|
||||
// 获取ResponseBody,解析出batchId和视频审核表id
|
||||
logger.Info("Unmarshaling ResponseBody...")
|
||||
result := &green20220302.VideoModerationResultResponseBody{}
|
||||
|
@ -27,14 +27,11 @@ func HandleVideoModerationContent(content string) (batchId string, isBatchFinish
|
|||
return
|
||||
}
|
||||
|
||||
batchId, isBatchFinished, err = handleVideoModerationResultResponseBody(result)
|
||||
err = handleVideoModerationResultResponseBody(result)
|
||||
return
|
||||
}
|
||||
|
||||
func handleVideoModerationResultResponseBody(result *green20220302.VideoModerationResultResponseBody) (batchId string, isBatchFinished bool, err error) {
|
||||
|
||||
batchId = ""
|
||||
isBatchFinished = false
|
||||
func handleVideoModerationResultResponseBody(result *green20220302.VideoModerationResultResponseBody) (err error) {
|
||||
|
||||
isTaskCompleted := false
|
||||
isActionCompleted := false
|
||||
|
@ -83,10 +80,9 @@ func handleVideoModerationResultResponseBody(result *green20220302.VideoModerati
|
|||
logger.Info("video moderation task of id %v has finished...", tcb.VideoModerationTask.GetId())
|
||||
|
||||
// 如果批次任务已经完成,从map中移除该批次任务控制块
|
||||
batchId = btcb.BatchId
|
||||
batchId := btcb.BatchId
|
||||
btcb.FinishATask()
|
||||
if btcb.IsBatchFinished() {
|
||||
isBatchFinished = true
|
||||
removeBtcb(btcb.BatchId)
|
||||
}
|
||||
logger.Info("video moderation batch task of batch_id %v has finished and been removed, all referenced request will be regarded as expired...", batchId)
|
||||
|
|
|
@ -168,7 +168,7 @@ func handleVideoModerationResponse(resp *green20220302.VideoModerationResponse,
|
|||
}
|
||||
|
||||
if !isSuccess {
|
||||
_, _, rErr := handleVideoModerationResultResponseBody(&green20220302.VideoModerationResultResponseBody{
|
||||
rErr := handleVideoModerationResultResponseBody(&green20220302.VideoModerationResultResponseBody{
|
||||
Code: goproto.Int32(code),
|
||||
Message: goproto.String(msg),
|
||||
Data: &green20220302.VideoModerationResultResponseBodyData{
|
||||
|
|
Loading…
Reference in New Issue