From 7ec3af4584bad53750c8ea7c3e8456e18497b067 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 1 Aug 2024 16:21:48 +0800 Subject: [PATCH 1/3] by Robin at 20240801 --- app/mix/service/utilservice.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 682b5a8c..b07e4a33 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -881,6 +881,16 @@ func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneM } imageIds = imageIds[:mediaVisibleRange] vo.MediaComp.ImageIds = util.Int64Slice(imageIds) + } else if vo.GetMType() == consts.MediaTypeVideo { + videoIdForUploadFail, err := apollo.GetIntValue(consts.VideoIdForUploadFail, apollo.ApolloOpts().SetNamespace("application")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + } + videoIds := vo.MediaComp.GetVideoIds() + for i := range videoIds { + videoIds[i] = int64(videoIdForUploadFail) + } + vo.MediaComp.VideoIds = util.Int64Slice(videoIds) } } From 0b2c83e21540b5b19f5c5cd2e9b40d4445955fe2 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 1 Aug 2024 16:52:27 +0800 Subject: [PATCH 2/3] by Robin at 20240801 --- app/mix/controller/zonemoment_api.go | 2 ++ app/mix/service/utilservice.go | 30 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/mix/controller/zonemoment_api.go b/app/mix/controller/zonemoment_api.go index 860a2367..c9f6fbb0 100644 --- a/app/mix/controller/zonemoment_api.go +++ b/app/mix/controller/zonemoment_api.go @@ -114,6 +114,7 @@ func ApiGetZoneMomentListByCreaterMid(ctx *gin.Context) { mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar } mediafiller.FillList(ctx, mediaFillableList) + service.DefaultService.UtilEncryptVideosForZoneMomentVOs(list) data := &zonemomentproto.ApiListByCreaterMidData{ List: list, @@ -150,6 +151,7 @@ func ApiGetZoneMomentListByZid(ctx *gin.Context) { mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar } mediafiller.FillList(ctx, mediaFillableList) + service.DefaultService.UtilEncryptVideosForZoneMomentVOs(list) data := &zonemomentproto.ApiListByZidData{ List: list, diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index b07e4a33..ff1d4969 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -881,16 +881,6 @@ func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneM } imageIds = imageIds[:mediaVisibleRange] vo.MediaComp.ImageIds = util.Int64Slice(imageIds) - } else if vo.GetMType() == consts.MediaTypeVideo { - videoIdForUploadFail, err := apollo.GetIntValue(consts.VideoIdForUploadFail, apollo.ApolloOpts().SetNamespace("application")) - if err != nil { - logger.Error("Apollo read failed : %v", err) - } - videoIds := vo.MediaComp.GetVideoIds() - for i := range videoIds { - videoIds[i] = int64(videoIdForUploadFail) - } - vo.MediaComp.VideoIds = util.Int64Slice(videoIds) } } @@ -2071,3 +2061,23 @@ func (s *Service) utilSignHvyogoMessage(msg interfaces.HvyogoSignable) ([]byte, return resultBytes, nil } + +func (s *Service) UtilEncryptVideosForZoneMomentVOs(list []*zonemomentproto.ApiZoneMomentVO) { + videoIdForUploadFail, err := apollo.GetIntValue(consts.VideoIdForUploadFail, apollo.ApolloOpts().SetNamespace("application")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + } + + for _, vo := range list { + if vo.IsZoneMomentUnlocked == consts.IsZoneMomentUnlocked_No { + videoIds := vo.MediaComp.GetVideoIds() + for i := range videoIds { + videoIds[i] = int64(videoIdForUploadFail) + } + vo.MediaComp.VideoIds = util.Int64Slice(videoIds) + for _, video := range vo.MediaComp.Videos { + video.Urls = make([]string, 0) + } + } + } +} From 71df61c5ff30b42e0baf0b82b253e81eb1c0eec0 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 1 Aug 2024 20:22:48 +0800 Subject: [PATCH 3/3] by Robin at 20240801 --- app/mix/controller/zonemoment_api.go | 4 ++-- app/mix/service/utilservice.go | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/mix/controller/zonemoment_api.go b/app/mix/controller/zonemoment_api.go index c9f6fbb0..600a398c 100644 --- a/app/mix/controller/zonemoment_api.go +++ b/app/mix/controller/zonemoment_api.go @@ -114,7 +114,7 @@ func ApiGetZoneMomentListByCreaterMid(ctx *gin.Context) { mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar } mediafiller.FillList(ctx, mediaFillableList) - service.DefaultService.UtilEncryptVideosForZoneMomentVOs(list) + service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list) data := &zonemomentproto.ApiListByCreaterMidData{ List: list, @@ -151,7 +151,7 @@ func ApiGetZoneMomentListByZid(ctx *gin.Context) { mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar } mediafiller.FillList(ctx, mediaFillableList) - service.DefaultService.UtilEncryptVideosForZoneMomentVOs(list) + service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list) data := &zonemomentproto.ApiListByZidData{ List: list, diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index ff1d4969..c614d186 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -32,6 +32,7 @@ import ( "service/dbstruct" "service/library/apollo" "service/library/logger" + "service/library/mediafiller" "service/library/mycrypto" "service/library/redis" "service/library/validator" @@ -2062,12 +2063,22 @@ func (s *Service) utilSignHvyogoMessage(msg interfaces.HvyogoSignable) ([]byte, return resultBytes, nil } -func (s *Service) UtilEncryptVideosForZoneMomentVOs(list []*zonemomentproto.ApiZoneMomentVO) { +func (s *Service) UtilEncryptVideosForZoneMomentVOs(ctx *gin.Context, list []*zonemomentproto.ApiZoneMomentVO) { videoIdForUploadFail, err := apollo.GetIntValue(consts.VideoIdForUploadFail, apollo.ApolloOpts().SetNamespace("application")) if err != nil { logger.Error("Apollo read failed : %v", err) } + media := &dbstruct.MediaComponent{ + ImageIds: util.Int64Slice(make([]int64, 0)), + VideoIds: util.Int64Slice([]int64{int64(videoIdForUploadFail)}), + } + mediafiller.FillEntity(ctx, media) + vdi := &dbstruct.ToCVideo{} + if len(media.Videos) > 0 { + vdi = media.Videos[0] + } + for _, vo := range list { if vo.IsZoneMomentUnlocked == consts.IsZoneMomentUnlocked_No { videoIds := vo.MediaComp.GetVideoIds() @@ -2077,6 +2088,7 @@ func (s *Service) UtilEncryptVideosForZoneMomentVOs(list []*zonemomentproto.ApiZ vo.MediaComp.VideoIds = util.Int64Slice(videoIds) for _, video := range vo.MediaComp.Videos { video.Urls = make([]string, 0) + video.Urls = append(video.Urls, vdi.Urls...) } } }