From e979017e8d7e4f78a1235ade99097fe5a4d1d0c7 Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Thu, 11 Jan 2024 19:44:37 -0500 Subject: [PATCH] fix: pass message data only in send group message request --- go.mod | 2 +- go.sum | 4 ++-- pkg/mls/api/v1/service.go | 13 ++----------- pkg/mls/api/v1/service_test.go | 13 +++---------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index e813f3ba..b4b1e568 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/uptrace/bun/driver/pgdriver v1.1.16 github.com/waku-org/go-waku v0.8.0 github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3 - github.com/xmtp/proto/v3 v3.36.3-0.20240112003601-b127b3d5b7b9 + github.com/xmtp/proto/v3 v3.36.3-0.20240112004139-20d010b31f31 github.com/yoheimuta/protolint v0.39.0 go.uber.org/zap v1.24.0 golang.org/x/sync v0.3.0 diff --git a/go.sum b/go.sum index 356f73dd..c16e1973 100644 --- a/go.sum +++ b/go.sum @@ -1146,8 +1146,8 @@ github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0 github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3 h1:wzUffJGCTBGXIDyNU+1UBu1fn2Nzo+OQzM1pLrheh58= github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3/go.mod h1:bJREWk+NDnZYjgLQdAi8SUWuq/5pkMme4GqiffEhUF4= -github.com/xmtp/proto/v3 v3.36.3-0.20240112003601-b127b3d5b7b9 h1:iWIW7/LCIej+Aof/RglSUKU/+bIv1vFpD4vyOwQz4PY= -github.com/xmtp/proto/v3 v3.36.3-0.20240112003601-b127b3d5b7b9/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY= +github.com/xmtp/proto/v3 v3.36.3-0.20240112004139-20d010b31f31 h1:qp3MYtKaDfZmrL3l2YOdfleOARDaoI9zOVvtz5yPpTk= +github.com/xmtp/proto/v3 v3.36.3-0.20240112004139-20d010b31f31/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/yoheimuta/go-protoparser/v4 v4.6.0 h1:uvz1e9/5Ihsm4Ku8AJeDImTpirKmIxubZdSn0QJNdnw= github.com/yoheimuta/go-protoparser/v4 v4.6.0/go.mod h1:AHNNnSWnb0UoL4QgHPiOAg2BniQceFscPI5X/BZNHl8= diff --git a/pkg/mls/api/v1/service.go b/pkg/mls/api/v1/service.go index da3cefdc..28142c49 100644 --- a/pkg/mls/api/v1/service.go +++ b/pkg/mls/api/v1/service.go @@ -153,23 +153,14 @@ func (s *Service) SendGroupMessages(ctx context.Context, req *proto.SendGroupMes return nil, err } - messages := make([][]byte, len(req.Messages)) - for i, message := range req.Messages { - v1 := message.GetV1() - if v1 == nil { - return nil, status.Errorf(codes.InvalidArgument, "message must be v1") - } - messages[i] = v1.Data - } - - validationResults, err := s.validationService.ValidateGroupMessages(ctx, messages) + validationResults, err := s.validationService.ValidateGroupMessages(ctx, req.Messages) if err != nil { // TODO: Separate validation errors from internal errors return nil, status.Errorf(codes.InvalidArgument, "invalid group message: %s", err) } for i, result := range validationResults { - data := messages[i] + data := req.Messages[i] if err = requireReadyToSend(result.GroupId, data); err != nil { return nil, err diff --git a/pkg/mls/api/v1/service_test.go b/pkg/mls/api/v1/service_test.go index d4bbe67c..8f0c5c5c 100644 --- a/pkg/mls/api/v1/service_test.go +++ b/pkg/mls/api/v1/service_test.go @@ -231,16 +231,9 @@ func TestSendGroupMessages(t *testing.T) { mlsValidationService.mockValidateGroupMessages(groupId) _, err := svc.SendGroupMessages(ctx, &mlsv1.SendGroupMessagesRequest{ - Messages: []*message_contents.GroupMessage{{ - Version: &message_contents.GroupMessage_V1_{ - V1: &message_contents.GroupMessage_V1{ - Id: 1, - CreatedNs: 1, - GroupId: groupId, - Data: []byte("test"), - }, - }, - }}, + Messages: [][]byte{ + []byte("test"), + }, }) require.NoError(t, err)