Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

test-errcode
wangchuxiao 2 years ago
commit be79131498

@ -18,15 +18,9 @@ import (
func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) {
defer log.ZInfo(ctx, "RevokeMsg return line")
//if req.UserID == "" {
// return nil, errs.ErrArgs.Wrap("user_id is empty")
//}
//if req.RecvID == "" && req.GroupID == "" {
// return nil, errs.ErrArgs.Wrap("recv_id and group_id are empty")
//}
//if req.RecvID != "" && req.GroupID != "" {
// return nil, errs.ErrArgs.Wrap("recv_id and group_id cannot exist at the same time")
//}
if req.UserID == "" {
return nil, errs.ErrArgs.Wrap("user_id is empty")
}
if req.ConversationID == "" {
return nil, errs.ErrArgs.Wrap("conversation_id is empty")
}
@ -47,33 +41,39 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
if len(msgs) == 0 {
return nil, errs.ErrRecordNotFound.Wrap("msg not found")
}
if msgs[0].SendID == "" || msgs[0].RecvID == "" {
return nil, errs.ErrRecordNotFound.Wrap("sendID or recvID is empty")
}
// todo: 判断是否已经撤回
data, _ := json.Marshal(msgs[0])
log.ZInfo(ctx, "GetMsgBySeqs", "conversationID", req.ConversationID, "seq", req.Seq, "msg", string(data))
//sendID := msgs[0]
//if !tokenverify.IsAppManagerUid(ctx) {
// if req.GroupID == "" {
// if req.UserID != sendID {
// return nil, errs.ErrNoPermission.Wrap("no permission")
// }
// } else {
// members, err := m.Group.GetGroupMemberInfoMap(ctx, req.GroupID, utils.Distinct([]string{req.UserID, sendID}), true)
// if err != nil {
// return nil, err
// }
// if req.UserID != sendID {
// roleLevel := members[req.UserID].RoleLevel
// switch members[req.UserID].RoleLevel {
// case constant.GroupOwner:
// case constant.GroupAdmin:
// if roleLevel != constant.GroupOrdinaryUsers {
// return nil, errs.ErrNoPermission.Wrap("no permission")
// }
// default:
// return nil, errs.ErrNoPermission.Wrap("no permission")
// }
// }
// }
//}
if !tokenverify.IsAppManagerUid(ctx) {
switch msgs[0].SessionType {
case constant.SingleChatType:
if err := tokenverify.CheckAccessV3(ctx, msgs[0].SendID); err != nil {
return nil, err
}
case constant.SuperGroupChatType:
members, err := m.Group.GetGroupMemberInfoMap(ctx, msgs[0].RecvID, utils.Distinct([]string{req.UserID, msgs[0].SendID}), true)
if err != nil {
return nil, err
}
if req.UserID != msgs[0].SendID {
roleLevel := members[req.UserID].RoleLevel
switch members[req.UserID].RoleLevel {
case constant.GroupOwner:
case constant.GroupAdmin:
if roleLevel != constant.GroupOrdinaryUsers {
return nil, errs.ErrNoPermission.Wrap("no permission")
}
default:
return nil, errs.ErrNoPermission.Wrap("no permission")
}
}
default:
return nil, errs.ErrInternalServer.Wrap("msg sessionType not supported")
}
}
err = m.MsgDatabase.RevokeMsg(ctx, req.ConversationID, req.Seq, &unRelationTb.RevokeModel{
UserID: req.UserID,
Nickname: user.Nickname,
@ -110,7 +110,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
CreateTime: utils.GetCurrentTimestampByMill(),
ClientMsgID: utils.GetMsgID(req.UserID),
Options: config.GetOptionsByNotification(config.NotificationConf{
IsSendMsg: true,
IsSendMsg: false,
ReliabilityLevel: 2,
}),
OfflinePushInfo: nil,

@ -5,7 +5,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
func MsgPb2DB(msg *sdkws.MsgData) unrelation.MsgDataModel {
func MsgPb2DB(msg *sdkws.MsgData) *unrelation.MsgDataModel {
if msg == nil {
return nil
}
var msgDataModel unrelation.MsgDataModel
msgDataModel.SendID = msg.SendID
msgDataModel.RecvID = msg.RecvID
@ -24,21 +27,26 @@ func MsgPb2DB(msg *sdkws.MsgData) unrelation.MsgDataModel {
msgDataModel.CreateTime = msg.CreateTime
msgDataModel.Status = msg.Status
msgDataModel.Options = msg.Options
msgDataModel.OfflinePush = &unrelation.OfflinePushModel{
Title: msg.OfflinePushInfo.Title,
Desc: msg.OfflinePushInfo.Desc,
Ex: msg.OfflinePushInfo.Ex,
IOSPushSound: msg.OfflinePushInfo.IOSPushSound,
IOSBadgeCount: msg.OfflinePushInfo.IOSBadgeCount,
if msg.OfflinePushInfo != nil {
msgDataModel.OfflinePush = &unrelation.OfflinePushModel{
Title: msg.OfflinePushInfo.Title,
Desc: msg.OfflinePushInfo.Desc,
Ex: msg.OfflinePushInfo.Ex,
IOSPushSound: msg.OfflinePushInfo.IOSPushSound,
IOSBadgeCount: msg.OfflinePushInfo.IOSBadgeCount,
}
}
msgDataModel.AtUserIDList = msg.AtUserIDList
msgDataModel.AttachedInfo = msg.AttachedInfo
msgDataModel.Ex = msg.Ex
return msgDataModel
return &msgDataModel
}
func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {
if msgModel == nil {
return nil
}
var msg sdkws.MsgData
msg.SendID = msgModel.SendID
msg.RecvID = msgModel.RecvID
@ -57,12 +65,14 @@ func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {
msg.CreateTime = msgModel.CreateTime
msg.Status = msgModel.Status
msg.Options = msgModel.Options
msg.OfflinePushInfo = &sdkws.OfflinePushInfo{
Title: msgModel.OfflinePush.Title,
Desc: msgModel.OfflinePush.Desc,
Ex: msgModel.OfflinePush.Ex,
IOSPushSound: msgModel.OfflinePush.IOSPushSound,
IOSBadgeCount: msgModel.OfflinePush.IOSBadgeCount,
if msgModel.OfflinePush != nil {
msg.OfflinePushInfo = &sdkws.OfflinePushInfo{
Title: msgModel.OfflinePush.Title,
Desc: msgModel.OfflinePush.Desc,
Ex: msgModel.OfflinePush.Ex,
IOSPushSound: msgModel.OfflinePush.IOSPushSound,
IOSBadgeCount: msgModel.OfflinePush.IOSBadgeCount,
}
}
msg.AtUserIDList = msgModel.AtUserIDList
msg.AttachedInfo = msgModel.AttachedInfo

Loading…
Cancel
Save