diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index 8ff3e5906..11db094cd 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -103,7 +103,8 @@ func ManagementSendMsg(c *gin.Context) { //case constant.Location: case constant.Custom: data = CustomElem{} - //case constant.Revoke: + case constant.Revoke: + data = RevokeElem{} //case constant.HasReadReceipt: //case constant.Typing: //case constant.Quote: @@ -257,3 +258,7 @@ type CustomElem struct { type TextElem struct { Text string `mapstructure:"text" validate:"required"` } + +type RevokeElem struct { + Text string `mapstructure:"text" validate:"required"` +} diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index e0e8acf68..3f8d1b88b 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -78,9 +78,10 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string sortkeys.Uint32s(seqList) seqMsgs, err := d.GetMsgBySeqListMongo2(uid, seqList, operationID) if err != nil { - return err + return utils.Wrap(err, "") } for _, seqMsg := range seqMsgs { + log.NewDebug(operationID, utils.GetSelfFuncName(), *seqMsg) seqMsg.Status = constant.MsgDeleted if err = d.ReplaceMsgBySeq(uid, seqMsg, operationID); err != nil { log.NewError(operationID, utils.GetSelfFuncName(), "ReplaceMsgListBySeq error", err.Error()) @@ -90,20 +91,25 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string } func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operationID string) error { - log.NewInfo(operationID, utils.GetSelfFuncName(), uid, msg) + log.NewInfo(operationID, utils.GetSelfFuncName(), uid, *msg) ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat) uid = getSeqUid(uid, msg.Seq) seqIndex := getMsgIndex(msg.Seq) s := fmt.Sprintf("msg.%d.msg", seqIndex) log.NewDebug(operationID, utils.GetSelfFuncName(), seqIndex, s) + bytes, err := proto.Marshal(msg) + if err != nil { + log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal", err.Error()) + return utils.Wrap(err, "") + } updateResult, err := c.UpdateOne( ctx, bson.M{"uid": uid}, - bson.M{"$set": bson.M{s: msg}}) + bson.M{"$set": bson.M{s: bytes}}) log.NewInfo(operationID, utils.GetSelfFuncName(), updateResult) if err != nil { log.NewError(operationID, utils.GetSelfFuncName(), "UpdateOne", err.Error()) - return err + return utils.Wrap(err, "") } return nil }