Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

test-errcode
skiffer-git 2 years ago
commit 56436adf4d

@ -3,9 +3,10 @@ package main
import ( import (
"Open_IM/internal/cron_task" "Open_IM/internal/cron_task"
"fmt" "fmt"
"time"
) )
func main() { func main() {
fmt.Println("start cronTask") fmt.Println(time.Now(), "start cronTask")
cronTask.StartCronTask() cronTask.StartCronTask()
} }

@ -341,6 +341,10 @@ callback:
enable: false enable: false
callbackTimeOut: 2 callbackTimeOut: 2
callbackFailedContinue: true # 回调超时是否继续 callbackFailedContinue: true # 回调超时是否继续
callbackBeforeMemberJoinGroup:
enable: false
callbackTimeOut: 2
callbackFailedContinue: true # 回调超时是否继续
notification: notification:
groupCreated: groupCreated:

@ -199,7 +199,6 @@ func ForceLogout(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return return
} }
req := &rpc.ForceLogoutReq{} req := &rpc.ForceLogoutReq{}
utils.CopyStructFields(req, &params) utils.CopyStructFields(req, &params)

@ -52,6 +52,10 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
fallthrough fallthrough
case constant.File: case constant.File:
fallthrough fallthrough
case constant.CustomNotTriggerConversation:
fallthrough
case constant.CustomOnlineOnly:
fallthrough
case constant.AdvancedRevoke: case constant.AdvancedRevoke:
newContent = utils.StructToJsonString(params.Content) newContent = utils.StructToJsonString(params.Content)
case constant.Revoke: case constant.Revoke:

@ -2,14 +2,82 @@ package cronTask
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/msg"
server_api_params "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"os/exec"
"testing" "testing"
"time"
) )
func getMsgListFake(num int) []*pbMsg.MsgDataToMQ {
var msgList []*pbMsg.MsgDataToMQ
for i := 1; i < num; i++ {
msgList = append(msgList, &pbMsg.MsgDataToMQ{
Token: "tk",
OperationID: "operationID",
MsgData: &server_api_params.MsgData{
SendID: "sendID1",
RecvID: "recvID1",
GroupID: "",
ClientMsgID: "xxx",
ServerMsgID: "xxx",
SenderPlatformID: 1,
SenderNickname: "testNickName",
SenderFaceURL: "testFaceURL",
SessionType: 1,
MsgFrom: 100,
ContentType: 101,
Content: []byte("testFaceURL"),
Seq: uint32(i),
SendTime: time.Now().Unix(),
CreateTime: time.Now().Unix(),
Status: 1,
},
})
}
return msgList
}
func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) { func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
operationID := getCronTaskOperationID() operationID := getCronTaskOperationID()
testUserIDList := []string{"test_del_id1", "test_del_id2", "test_del_id3", "test_del_id4", "test_del_id5"} testUID1 := "test_del_id1"
//testUID2 := "test_del_id2"
//testUID3 := "test_del_id3"
//testUID4 := "test_del_id4"
//testUID5 := "test_del_id5"
//testUID6 := "test_del_id6"
testUserIDList := []string{testUID1}
err := db.DB.SetUserMaxSeq(testUID1, 500)
err = db.DB.BatchInsertChat2DB(testUID1, getMsgListFake(500), testUID1+"-"+operationID, 500)
if err != nil {
t.Error(err.Error(), testUID1)
}
//db.DB.SetUserMaxSeq(testUID1, 6000)
//db.DB.BatchInsertChat2DB()
//
//db.DB.SetUserMaxSeq(testUID1, 4999)
//db.DB.BatchInsertChat2DB()
//
//db.DB.SetUserMaxSeq(testUID1, 30000)
//db.DB.BatchInsertChat2DB()
//
//db.DB.SetUserMaxSeq(testUID1, 9999)
//db.DB.BatchInsertChat2DB()
cmd := exec.Command("/bin/bash", "unset $CONFIG_NAME")
_, err = cmd.StdoutPipe()
if err != nil {
return
}
//执行命令
if err := cmd.Start(); err != nil {
return
}
for _, userID := range testUserIDList { for _, userID := range testUserIDList {
operationID = userID + "-" + operationID operationID = userID + "-" + operationID
if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil { if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil {

@ -31,14 +31,14 @@ func StartCronTask() {
if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil { if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), userID) log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), userID)
} }
//if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil { if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
// log.NewError(operationID, utils.GetSelfFuncName(), userID, err) log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
//} }
} }
} else { } else {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
} }
return //return
// working group msg clear // working group msg clear
workingGroupIDList, err := im_mysql_model.GetGroupIDListByGroupType(constant.WorkingGroup) workingGroupIDList, err := im_mysql_model.GetGroupIDListByGroupType(constant.WorkingGroup)
if err == nil { if err == nil {
@ -53,9 +53,9 @@ func StartCronTask() {
if err := ResetUserGroupMinSeq(operationID, groupID, userIDList); err != nil { if err := ResetUserGroupMinSeq(operationID, groupID, userIDList); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userIDList) log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userIDList)
} }
//if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil { if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
// log.NewError(operationID, utils.GetSelfFuncName(), groupID, err) log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
//} }
} }
} else { } else {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), err.Error())

@ -40,7 +40,12 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
return return
} }
log.NewInfo(m.OperationID, "Basic Info Authentication Success", m.SendID, m.MsgIncr, m.ReqIdentifier) log.NewInfo(m.OperationID, "Basic Info Authentication Success", m.SendID, m.MsgIncr, m.ReqIdentifier)
if m.SendID != conn.userID {
if err = conn.Close(); err != nil {
log.NewError(m.OperationID, "close ws conn failed", conn.userID, "send id", m.SendID, err.Error())
return
}
}
switch m.ReqIdentifier { switch m.ReqIdentifier {
case constant.WSGetNewestSeq: case constant.WSGetNewestSeq:
log.NewInfo(m.OperationID, "getSeqReq ", m.SendID, m.MsgIncr, m.ReqIdentifier) log.NewInfo(m.OperationID, "getSeqReq ", m.SendID, m.MsgIncr, m.ReqIdentifier)

@ -11,8 +11,10 @@ import (
pbRelay "Open_IM/pkg/proto/relay" pbRelay "Open_IM/pkg/proto/relay"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"bytes" "bytes"
"compress/gzip"
"context" "context"
"encoding/gob" "encoding/gob"
"io/ioutil"
"strings" "strings"
go_redis "github.com/go-redis/redis/v8" go_redis "github.com/go-redis/redis/v8"
@ -31,6 +33,8 @@ type UserConn struct {
w *sync.Mutex w *sync.Mutex
platformID int32 platformID int32
PushedMaxSeq uint32 PushedMaxSeq uint32
IsCompress bool
userID string
} }
type WServer struct { type WServer struct {
wsAddr string wsAddr string
@ -75,7 +79,12 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
log.Error(operationID, "upgrade http conn err", err.Error(), query) log.Error(operationID, "upgrade http conn err", err.Error(), query)
return return
} else { } else {
newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0} var isCompress = false
if r.Header.Get("compression") == "gzip" {
log.NewDebug(operationID, query["sendID"][0], "enable compression")
isCompress = true
}
newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0, isCompress, query["sendID"][0]}
userCount++ userCount++
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], operationID) ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], operationID)
go ws.readMsg(newConn) go ws.readMsg(newConn)
@ -97,6 +106,24 @@ func (ws *WServer) readMsg(conn *UserConn) {
ws.delUserConn(conn) ws.delUserConn(conn)
return return
} }
log.NewDebug("", "size", utils.ByteSize(uint64(len(msg))))
if conn.IsCompress {
buff := bytes.NewBuffer(msg)
reader, err := gzip.NewReader(buff)
if err != nil {
log.NewWarn("", "un gzip read failed")
continue
}
msg, err = ioutil.ReadAll(reader)
if err != nil {
log.NewWarn("", "ReadAll failed")
continue
}
err = reader.Close()
if err != nil {
log.NewWarn("", "reader close failed")
}
}
ws.msgParse(conn, msg) ws.msgParse(conn, msg)
} }
} }
@ -110,6 +137,17 @@ func (ws *WServer) SetWriteTimeout(conn *UserConn, timeout int) {
func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error { func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error {
conn.w.Lock() conn.w.Lock()
defer conn.w.Unlock() defer conn.w.Unlock()
if conn.IsCompress {
var buffer bytes.Buffer
gz := gzip.NewWriter(&buffer)
if _, err := gz.Write(msg); err != nil {
return utils.Wrap(err, "")
}
if err := gz.Close(); err != nil {
return utils.Wrap(err, "")
}
msg = buffer.Bytes()
}
conn.SetWriteDeadline(time.Now().Add(time.Duration(60) * time.Second)) conn.SetWriteDeadline(time.Now().Add(time.Duration(60) * time.Second))
return conn.WriteMessage(a, msg) return conn.WriteMessage(a, msg)
} }

@ -78,6 +78,8 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
case constant.FieldUnread: case constant.FieldUnread:
isSyncConversation = false isSyncConversation = false
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": conversation.UpdateUnreadCountTime}) err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": conversation.UpdateUnreadCountTime})
case constant.FieldBurnDuration:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"burn_duration": conversation.BurnDuration})
} }
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error())

@ -4,6 +4,7 @@ import (
cbApi "Open_IM/pkg/call_back_struct" cbApi "Open_IM/pkg/call_back_struct"
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/http" "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
pbGroup "Open_IM/pkg/proto/group" pbGroup "Open_IM/pkg/proto/group"
@ -19,6 +20,8 @@ func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallback
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), req.String()) log.NewDebug(req.OperationID, utils.GetSelfFuncName(), req.String())
commonCallbackReq := &cbApi.CallbackBeforeCreateGroupReq{ commonCallbackReq := &cbApi.CallbackBeforeCreateGroupReq{
CallbackCommand: constant.CallbackBeforeCreateGroupCommand, CallbackCommand: constant.CallbackBeforeCreateGroupCommand,
GroupInfo: *req.GroupInfo,
InitMemberList: req.InitMemberList,
} }
resp := &cbApi.CallbackBeforeCreateGroupResp{ resp := &cbApi.CallbackBeforeCreateGroupResp{
CommonCallbackResp: &callbackResp, CommonCallbackResp: &callbackResp,
@ -41,7 +44,7 @@ func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallback
req.GroupInfo.GroupID = *resp.GroupID req.GroupInfo.GroupID = *resp.GroupID
} }
if resp.GroupName != nil { if resp.GroupName != nil {
req.GroupInfo.GroupName = *resp.GroupID req.GroupInfo.GroupName = *resp.GroupName
} }
if resp.Notification != nil { if resp.Notification != nil {
req.GroupInfo.Notification = *resp.Notification req.GroupInfo.Notification = *resp.Notification
@ -68,7 +71,7 @@ func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallback
req.GroupInfo.GroupType = *resp.GroupType req.GroupInfo.GroupType = *resp.GroupType
} }
if resp.NeedVerification != nil { if resp.NeedVerification != nil {
req.GroupInfo.NeedVerification = *resp.GroupType req.GroupInfo.NeedVerification = *resp.NeedVerification
} }
if resp.LookMemberInfo != nil { if resp.LookMemberInfo != nil {
req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo
@ -76,3 +79,48 @@ func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallback
} }
return callbackResp return callbackResp
} }
func CallbackBeforeMemberJoinGroup(operationID string, groupMember *db.GroupMember, groupEx string) cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackBeforeMemberJoinGroup.Enable {
return callbackResp
}
log.NewDebug(operationID, "args: ", *groupMember)
callbackReq := cbApi.CallbackBeforeMemberJoinGroupReq{
CallbackCommand: constant.CallbackBeforeMemberJoinGroupCommand,
GroupID: groupMember.GroupID,
UserID: groupMember.UserID,
Ex: groupMember.Ex,
GroupEx: groupEx,
}
resp := &cbApi.CallbackBeforeMemberJoinGroupResp{
CommonCallbackResp: &callbackResp,
}
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeMemberJoinGroupCommand, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error()
if !config.Config.Callback.CallbackBeforeMemberJoinGroup.CallbackFailedContinue {
callbackResp.ActionCode = constant.ActionForbidden
return callbackResp
} else {
callbackResp.ActionCode = constant.ActionAllow
return callbackResp
}
}
if resp.MuteEndTime != nil {
groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime)
}
if resp.FaceURL != nil {
groupMember.FaceURL = *resp.FaceURL
}
if resp.Ex != nil {
groupMember.Ex = *resp.Ex
}
if resp.NickName != nil {
groupMember.Nickname = *resp.NickName
}
if resp.RoleLevel != nil {
groupMember.RoleLevel = *resp.RoleLevel
}
return callbackResp
}

@ -20,6 +20,7 @@ import (
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"errors" "errors"
"fmt"
"math/big" "math/big"
"net" "net"
"strconv" "strconv"
@ -157,6 +158,16 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
groupMember := db.GroupMember{} groupMember := db.GroupMember{}
us := &db.User{} us := &db.User{}
if req.OwnerUserID != "" { if req.OwnerUserID != "" {
var userIDList []string
for _, v := range req.InitMemberList {
userIDList = append(userIDList, v.UserID)
}
userIDList = append(userIDList, req.OwnerUserID)
if err := s.DelGroupAndUserCache(req.OperationID, "", userIDList); err != nil {
log.NewError(req.OperationID, "DelGroupAndUserCache failed, ", err.Error(), userIDList)
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
}
us, err = imdb.GetUserByUserID(req.OwnerUserID) us, err = imdb.GetUserByUserID(req.OwnerUserID)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID) log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID)
@ -165,6 +176,21 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
//to group member //to group member
groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID, JoinSource: constant.JoinByInvitation, InviterUserID: req.OpUserID} groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID, JoinSource: constant.JoinByInvitation, InviterUserID: req.OpUserID}
utils.CopyStructFields(&groupMember, us) utils.CopyStructFields(&groupMember, us)
callbackResp := CallbackBeforeMemberJoinGroup(req.OperationID, &groupMember, groupInfo.Ex)
if callbackResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
}
if callbackResp.ActionCode != constant.ActionAllow {
if callbackResp.ErrCode == 0 {
callbackResp.ErrCode = 201
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
return &pbGroup.CreateGroupResp{
ErrCode: int32(callbackResp.ErrCode),
ErrMsg: callbackResp.ErrMsg,
}, nil
}
err = imdb.InsertIntoGroupMember(groupMember) err = imdb.InsertIntoGroupMember(groupMember)
if err != nil { if err != nil {
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember) log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
@ -188,6 +214,17 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
groupMember.JoinSource = constant.JoinByInvitation groupMember.JoinSource = constant.JoinByInvitation
groupMember.InviterUserID = req.OpUserID groupMember.InviterUserID = req.OpUserID
utils.CopyStructFields(&groupMember, us) utils.CopyStructFields(&groupMember, us)
callbackResp := CallbackBeforeMemberJoinGroup(req.OperationID, &groupMember, groupInfo.Ex)
if callbackResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
}
if callbackResp.ActionCode != constant.ActionAllow {
if callbackResp.ErrCode == 0 {
callbackResp.ErrCode = 201
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
continue
}
err = imdb.InsertIntoGroupMember(groupMember) err = imdb.InsertIntoGroupMember(groupMember)
if err != nil { if err != nil {
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember) log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
@ -231,11 +268,6 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
if len(okUserIDList) != 0 { if len(okUserIDList) != 0 {
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String()) log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
if req.GroupInfo.GroupType != constant.SuperGroup { if req.GroupInfo.GroupType != constant.SuperGroup {
for _, userID := range okUserIDList {
if err := rocksCache.DelJoinedGroupIDListFromCache(userID); err != nil {
log.NewWarn(req.OperationID, utils.GetSelfFuncName(), userID, err.Error())
}
}
chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList) chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList)
} else { } else {
for _, userID := range okUserIDList { for _, userID := range okUserIDList {
@ -362,7 +394,10 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp) log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp)
return &resp, nil return &resp, nil
} }
// if err := s.DelGroupAndUserCache(req.OperationID, req.GroupID, req.InvitedUserIDList); err != nil {
log.NewError(req.OperationID, "DelGroupAndUserCache failed", err.Error())
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
}
//from User: invite: applicant //from User: invite: applicant
//to user: invite: invited //to user: invite: invited
var okUserIDList []string var okUserIDList []string
@ -392,6 +427,15 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
toInsertInfo.OperatorUserID = req.OpUserID toInsertInfo.OperatorUserID = req.OpUserID
toInsertInfo.InviterUserID = req.OpUserID toInsertInfo.InviterUserID = req.OpUserID
toInsertInfo.JoinSource = constant.JoinByInvitation toInsertInfo.JoinSource = constant.JoinByInvitation
callbackResp := CallbackBeforeMemberJoinGroup(req.OperationID, &toInsertInfo, groupInfo.Ex)
if callbackResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
}
if callbackResp.ActionCode != constant.ActionAllow {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
continue
}
err = imdb.InsertIntoGroupMember(toInsertInfo) err = imdb.InsertIntoGroupMember(toInsertInfo)
if err != nil { if err != nil {
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", req.GroupID, toUserInfo.UserID, toUserInfo.Nickname, toUserInfo.FaceURL) log.NewError(req.OperationID, "InsertIntoGroupMember failed ", req.GroupID, toUserInfo.UserID, toUserInfo.Nickname, toUserInfo.FaceURL)
@ -473,40 +517,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
} }
} }
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
}
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: req.GroupID,
OperationID: req.OperationID,
})
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
}
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
if groupInfo.GroupType != constant.SuperGroup { if groupInfo.GroupType != constant.SuperGroup {
for _, userID := range okUserIDList {
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
}
}
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList) chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList)
} else { } else {
for _, v := range req.InvitedUserIDList { for _, v := range req.InvitedUserIDList {
@ -634,7 +645,10 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
log.NewError(req.OperationID, "failed, kick list 0") log.NewError(req.OperationID, "failed, kick list 0")
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}, nil return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}, nil
} }
if err := s.DelGroupAndUserCache(req.OperationID, req.GroupID, req.KickedUserIDList); err != nil {
log.NewError(req.OperationID, "DelGroupAndUserCache failed", err.Error())
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
}
//remove //remove
for _, v := range req.KickedUserIDList { for _, v := range req.KickedUserIDList {
kickedInfo, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, v) kickedInfo, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, v)
@ -701,42 +715,12 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
} }
} }
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
}
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: req.GroupID,
OperationID: req.OperationID,
})
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
}
if groupInfo.GroupType != constant.SuperGroup { if groupInfo.GroupType != constant.SuperGroup {
for _, userID := range okUserIDList { for _, userID := range okUserIDList {
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
}
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil { if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
} }
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
chat.MemberKickedNotification(req, okUserIDList) chat.MemberKickedNotification(req, okUserIDList)
} else { } else {
for _, userID := range okUserIDList { for _, userID := range okUserIDList {
@ -761,7 +745,6 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String()) log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
var resp pbGroup.GetGroupMembersInfoResp var resp pbGroup.GetGroupMembersInfoResp
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{} resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
for _, userID := range req.MemberList { for _, userID := range req.MemberList {
groupMember, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID) groupMember, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID)
if err != nil { if err != nil {
@ -773,24 +756,6 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
memberNode.JoinTime = int32(groupMember.JoinTime.Unix()) memberNode.JoinTime = int32(groupMember.JoinTime.Unix())
resp.MemberList = append(resp.MemberList, &memberNode) resp.MemberList = append(resp.MemberList, &memberNode)
} }
//groupMembers, err := rocksCache.GetAllGroupMembersInfoFromCache(req.GroupID)
//if err != nil {
// log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
// resp.ErrCode = constant.ErrDB.ErrCode
// resp.ErrMsg = constant.ErrDB.ErrMsg
// return &resp, nil
//}
//for _, member := range groupMembers {
// if utils.IsContain(member.UserID, req.MemberList) {
// var memberNode open_im_sdk.GroupMemberFullInfo
// utils.CopyStructFields(&memberNode, member)
// memberNode.JoinTime = int32(member.JoinTime.Unix())
// resp.MemberList = append(resp.MemberList, &memberNode)
// }
//}
resp.ErrCode = 0
log.NewInfo(req.OperationID, "GetGroupMembersInfo rpc return ", resp.String()) log.NewInfo(req.OperationID, "GetGroupMembersInfo rpc return ", resp.String())
return &resp, nil return &resp, nil
} }
@ -875,7 +840,11 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.GroupID, req.FromUserID) log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.GroupID, req.FromUserID)
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
if err != nil {
log.NewError(req.OperationID, "GetGroupInfoFromCache failed ", err.Error(), req.GroupID, req.FromUserID)
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
if req.HandleResult == constant.GroupResponseAgree { if req.HandleResult == constant.GroupResponseAgree {
user, err := imdb.GetUserByUserID(req.FromUserID) user, err := imdb.GetUserByUserID(req.FromUserID)
if err != nil { if err != nil {
@ -891,6 +860,22 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
member.Nickname = user.Nickname member.Nickname = user.Nickname
member.JoinSource = request.JoinSource member.JoinSource = request.JoinSource
member.InviterUserID = request.InviterUserID member.InviterUserID = request.InviterUserID
callbackResp := CallbackBeforeMemberJoinGroup(req.OperationID, &member, groupInfo.Ex)
if callbackResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
}
if callbackResp.ActionCode != constant.ActionAllow {
if callbackResp.ErrCode == 0 {
callbackResp.ErrCode = 201
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
return &pbGroup.GroupApplicationResponseResp{
CommonResp: &pbGroup.CommonResp{
ErrCode: int32(callbackResp.ErrCode),
ErrMsg: callbackResp.ErrMsg,
},
}, nil
}
err = imdb.InsertIntoGroupMember(member) err = imdb.InsertIntoGroupMember(member)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), member) log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), member)
@ -980,7 +965,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
groupInfo, err := imdb.GetGroupInfoByGroupID(req.GroupID) groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.GroupID, err) log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.GroupID, err)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
@ -1000,40 +985,34 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
//to group member //to group member
groupMember := db.GroupMember{GroupID: req.GroupID, RoleLevel: constant.GroupOrdinaryUsers, OperatorUserID: req.OpUserID} groupMember := db.GroupMember{GroupID: req.GroupID, RoleLevel: constant.GroupOrdinaryUsers, OperatorUserID: req.OpUserID}
utils.CopyStructFields(&groupMember, us) utils.CopyStructFields(&groupMember, us)
err = imdb.InsertIntoGroupMember(groupMember) callbackResp := CallbackBeforeMemberJoinGroup(req.OperationID, &groupMember, groupInfo.Ex)
if err != nil { if callbackResp.ErrCode != 0 {
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember) log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: constant.ErrInternal.ErrMsg}}, nil
} }
cacheClient := pbCache.NewCacheClient(etcdConn) if callbackResp.ActionCode != constant.ActionAllow {
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{ if callbackResp.ErrCode == 0 {
GroupID: req.GroupID, callbackResp.ErrCode = 201
OperationID: req.OperationID, }
}) log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
if err != nil { return &pbGroup.JoinGroupResp{
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error()) CommonResp: &pbGroup.CommonResp{
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil ErrCode: int32(callbackResp.ErrCode),
ErrMsg: callbackResp.ErrMsg,
},
}, nil
} }
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String()) if err := s.DelGroupAndUserCache(req.OperationID, req.GroupID, []string{req.OpUserID}); err != nil {
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil log.NewError(req.OperationID, "DelGroupAndUserCache failed, ", err.Error(), req.OpUserID)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
} }
err = rocksCache.DelJoinedGroupIDListFromCache(req.OpUserID)
err = imdb.InsertIntoGroupMember(groupMember)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
} return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
}
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
chat.MemberEnterDirectlyNotification(req.GroupID, req.OpUserID, req.OperationID) chat.MemberEnterDirectlyNotification(req.GroupID, req.OpUserID, req.OperationID)
log.NewInfo(req.OperationID, "JoinGroup rpc return ") log.NewInfo(req.OperationID, "JoinGroup rpc return ")
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1042,7 +1021,6 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil
} }
} }
var groupRequest db.GroupRequest var groupRequest db.GroupRequest
groupRequest.UserID = req.OpUserID groupRequest.UserID = req.OpUserID
groupRequest.ReqMsg = req.ReqMessage groupRequest.ReqMsg = req.ReqMessage
@ -1053,13 +1031,11 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest) log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
//_, err = imdb.GetGroupMemberListByGroupIDAndRoleLevel(req.GroupID, constant.GroupOwner) //_, err = imdb.GetGroupMemberListByGroupIDAndRoleLevel(req.GroupID, constant.GroupOwner)
//if err != nil { //if err != nil {
// log.NewError(req.OperationID, "GetGroupMemberListByGroupIDAndRoleLevel failed ", err.Error(), req.GroupID, constant.GroupOwner) // log.NewError(req.OperationID, "GetGroupMemberListByGroupIDAndRoleLevel failed ", err.Error(), req.GroupID, constant.GroupOwner)
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil // return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
//} //}
chat.JoinGroupApplicationNotification(req) chat.JoinGroupApplicationNotification(req)
log.NewInfo(req.OperationID, "JoinGroup rpc return ") log.NewInfo(req.OperationID, "JoinGroup rpc return ")
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1079,6 +1055,11 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := s.DelGroupAndUserCache(req.OperationID, req.GroupID, []string{req.OpUserID}); err != nil {
log.NewError(req.OperationID, "DelGroupAndUserCache failed, ", err.Error(), req.OpUserID)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
err = imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, req.OpUserID) err = imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, req.OpUserID)
if err != nil { if err != nil {
log.NewError(req.OperationID, "DeleteGroupMemberByGroupIdAndUserId failed ", err.Error(), req.GroupID, req.OpUserID) log.NewError(req.OperationID, "DeleteGroupMemberByGroupIdAndUserId failed ", err.Error(), req.GroupID, req.OpUserID)
@ -1121,35 +1102,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
} }
} }
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: constant.ErrInternal.ErrMsg}}, nil
}
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: req.GroupID,
OperationID: req.OperationID,
})
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
}
if groupInfo.GroupType != constant.SuperGroup { if groupInfo.GroupType != constant.SuperGroup {
if err := rocksCache.DelJoinedGroupIDListFromCache(req.OpUserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID)
}
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.OpUserID); err != nil { if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.OpUserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
@ -1158,10 +1111,13 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
if err := rocksCache.DelJoinedSuperGroupIDListFromCache(req.OpUserID); err != nil { if err := rocksCache.DelJoinedSuperGroupIDListFromCache(req.OpUserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID)
} }
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
}
chat.SuperGroupNotification(req.OperationID, req.OpUserID, req.OpUserID) chat.SuperGroupNotification(req.OperationID, req.OpUserID, req.OpUserID)
} }
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}) log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{}})
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{}}, nil
} }
func hasAccess(req *pbGroup.SetGroupInfoReq) bool { func hasAccess(req *pbGroup.SetGroupInfoReq) bool {
@ -1259,16 +1215,15 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
groupInfo.NotificationUserID = req.OpUserID groupInfo.NotificationUserID = req.OpUserID
groupInfo.NotificationUpdateTime = time.Now() groupInfo.NotificationUpdateTime = time.Now()
} }
if err := rocksCache.DelGroupInfoFromCache(req.GroupInfoForSet.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelGroupInfoFromCache failed ", err.Error(), req.GroupInfoForSet.GroupID)
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
err = imdb.SetGroupInfo(groupInfo) err = imdb.SetGroupInfo(groupInfo)
if err != nil { if err != nil {
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo) log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupInfoFromCache(req.GroupInfoForSet.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelGroupInfoFromCache failed ", err.Error(), req.GroupInfoForSet.GroupID)
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}}) log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
if changedType != 0 { if changedType != 0 {
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfoForSet.GroupID, groupName, notification, introduction, faceURL, req.GroupInfoForSet.NeedVerification) chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfoForSet.GroupID, groupName, notification, introduction, faceURL, req.GroupInfoForSet.NeedVerification)
@ -1339,6 +1294,18 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
log.NewError(req.OperationID, "same owner ", req.OldOwnerUserID, req.NewOwnerUserID) log.NewError(req.OperationID, "same owner ", req.OldOwnerUserID, req.NewOwnerUserID)
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil
} }
err = rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.NewOwnerUserID)
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberInfoFromCache failed ", req.GroupID, req.NewOwnerUserID)
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
err = rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.OldOwnerUserID)
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberInfoFromCache failed ", req.GroupID, req.OldOwnerUserID)
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.OldOwnerUserID, RoleLevel: constant.GroupOrdinaryUsers} groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.OldOwnerUserID, RoleLevel: constant.GroupOrdinaryUsers}
err = imdb.UpdateGroupMemberInfo(groupMemberInfo) err = imdb.UpdateGroupMemberInfo(groupMemberInfo)
if err != nil { if err != nil {
@ -1351,14 +1318,7 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo) log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo)
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
err = rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.NewOwnerUserID)
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberInfoFromCache failed ", req.GroupID, req.NewOwnerUserID)
}
err = rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.OldOwnerUserID)
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberInfoFromCache failed ", req.GroupID, req.OldOwnerUserID)
}
chat.GroupOwnerTransferredNotification(req) chat.GroupOwnerTransferredNotification(req)
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1503,6 +1463,15 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
if err := s.DelGroupAndUserCache(req.OperationID, req.GroupID, nil); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
err := imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusDismissed) err := imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusDismissed)
if err != nil { if err != nil {
log.NewError(req.OperationID, "OperateGroupStatus failed ", req.GroupID, constant.GroupStatusDismissed) log.NewError(req.OperationID, "OperateGroupStatus failed ", req.GroupID, constant.GroupStatusDismissed)
@ -1554,34 +1523,8 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
if err != nil { if err != nil {
log.NewError(req.OperationID, "DeleteGroupMemberByGroupID failed ", req.GroupID) log.NewError(req.OperationID, "DeleteGroupMemberByGroupID failed ", req.GroupID)
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
} }
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 500, ErrMsg: errMsg}}, nil
}
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: req.GroupID,
OperationID: req.OperationID,
})
if err != nil {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 500, ErrMsg: err.Error()}}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}, nil
}
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
} }
@ -1605,7 +1548,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
} }
mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.UserID) mutedInfo, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, req.UserID)
if err != nil { if err != nil {
errMsg := req.OperationID + " GetGroupMemberInfoByGroupIDAndUserID failed " + req.GroupID + req.UserID + err.Error() errMsg := req.OperationID + " GetGroupMemberInfoByGroupIDAndUserID failed " + req.GroupID + req.UserID + err.Error()
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
@ -1619,17 +1562,17 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, req.UserID)
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID} groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
groupMemberInfo.MuteEndTime = time.Unix(int64(time.Now().Second())+int64(req.MutedSeconds), time.Now().UnixNano()) groupMemberInfo.MuteEndTime = time.Unix(int64(time.Now().Second())+int64(req.MutedSeconds), time.Now().UnixNano())
err = imdb.UpdateGroupMemberInfo(groupMemberInfo) err = imdb.UpdateGroupMemberInfo(groupMemberInfo)
if err != nil { if err != nil {
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo) log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
chat.GroupMemberMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, req.MutedSeconds) chat.GroupMemberMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, req.MutedSeconds)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1663,6 +1606,10 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.UserID errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.UserID
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID} groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
groupMemberInfo.MuteEndTime = time.Unix(0, 0) groupMemberInfo.MuteEndTime = time.Unix(0, 0)
@ -1671,9 +1618,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo) log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID) chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1707,15 +1652,17 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
// errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.OpUserID + err.Error() // errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.OpUserID + err.Error()
// return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil // return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
//} //}
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
err = imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusMuted) err = imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusMuted)
if err != nil { if err != nil {
log.Error(req.OperationID, "OperateGroupStatus failed ", err.Error(), req.GroupID, constant.GroupStatusMuted) log.Error(req.OperationID, "OperateGroupStatus failed ", err.Error(), req.GroupID, constant.GroupStatusMuted)
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID) chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1723,7 +1670,6 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) { func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID) opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
if err != nil { if err != nil {
errMsg := req.OperationID + " getGroupUserLevel failed " + req.GroupID + req.OpUserID + err.Error() errMsg := req.OperationID + " getGroupUserLevel failed " + req.GroupID + req.OpUserID + err.Error()
@ -1735,7 +1681,6 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
} }
//mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.) //mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.)
//if err != nil { //if err != nil {
// errMsg := req.OperationID + " GetGroupMemberInfoByGroupIDAndUserID failed " + req.GroupID + req.OpUserID + err.Error() // errMsg := req.OperationID + " GetGroupMemberInfoByGroupIDAndUserID failed " + req.GroupID + req.OpUserID + err.Error()
@ -1750,14 +1695,16 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
// return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil // return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
//} //}
log.Debug(req.OperationID, "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk}) log.Debug(req.OperationID, "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk})
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
err = imdb.UpdateGroupInfoDefaultZero(req.GroupID, map[string]interface{}{"status": constant.GroupOk}) err = imdb.UpdateGroupInfoDefaultZero(req.GroupID, map[string]interface{}{"status": constant.GroupOk})
if err != nil { if err != nil {
log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), req.GroupID) log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), req.GroupID)
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID) chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1785,15 +1732,17 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
} else { } else {
groupMemberInfo.Nickname = req.Nickname groupMemberInfo.Nickname = req.Nickname
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
}
err := imdb.UpdateGroupMemberInfo(groupMemberInfo) err := imdb.UpdateGroupMemberInfo(groupMemberInfo)
if err != nil { if err != nil {
errMsg := req.OperationID + " UpdateGroupMemberInfo failed " + err.Error() errMsg := req.OperationID + " UpdateGroupMemberInfo failed " + err.Error()
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID) chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -1802,6 +1751,12 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (resp *pbGroup.SetGroupMemberInfoResp, err error) { func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (resp *pbGroup.SetGroupMemberInfoResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbGroup.SetGroupMemberInfoResp{CommonResp: &pbGroup.CommonResp{}} resp = &pbGroup.SetGroupMemberInfoResp{CommonResp: &pbGroup.CommonResp{}}
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
resp.CommonResp.ErrMsg = err.Error()
return resp, nil
}
groupMember := db.GroupMember{ groupMember := db.GroupMember{
GroupID: req.GroupID, GroupID: req.GroupID,
UserID: req.UserID, UserID: req.UserID,
@ -1826,9 +1781,6 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error() resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error()
return resp, nil return resp, nil
} }
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, req.UserID)
}
if req.RoleLevel != nil { if req.RoleLevel != nil {
switch req.RoleLevel.Value { switch req.RoleLevel.Value {
case constant.GroupOrdinaryUsers: case constant.GroupOrdinaryUsers:
@ -1867,3 +1819,47 @@ func (s *groupServer) GetGroupAbstractInfo(c context.Context, req *pbGroup.GetGr
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", resp.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", resp.String())
return resp, nil return resp, nil
} }
func (s *groupServer) DelGroupAndUserCache(operationID, groupID string, userIDList []string) error {
if groupID != "" {
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, operationID)
if etcdConn == nil {
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
log.NewError(operationID, errMsg)
return errors.New("etcdConn is nil")
}
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: groupID,
OperationID: operationID,
})
if err != nil {
log.NewError(operationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
return utils.Wrap(err, "")
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(operationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return errors.New(fmt.Sprintf("errMsg is %s, errCode is %d", cacheResp.CommonResp.ErrMsg, cacheResp.CommonResp.ErrCode))
}
err = rocksCache.DelGroupMemberListHashFromCache(groupID)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), groupID, err.Error())
return utils.Wrap(err, "")
}
err = rocksCache.DelGroupMemberNumFromCache(groupID)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID)
return utils.Wrap(err, "")
}
}
if userIDList != nil {
for _, userID := range userIDList {
err := rocksCache.DelJoinedGroupIDListFromCache(userID)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
return utils.Wrap(err, "")
}
}
}
return nil
}

@ -159,7 +159,7 @@ func BlackDeletedNotification(req *pbFriend.RemoveBlacklistReq) {
} }
func UserInfoUpdatedNotification(operationID, userID string, needNotifiedUserID string) { func UserInfoUpdatedNotification(operationID, userID string, needNotifiedUserID string) {
selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: userID} selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: needNotifiedUserID}
commID := pbFriend.CommID{FromUserID: userID, ToUserID: needNotifiedUserID, OpUserID: userID, OperationID: operationID} commID := pbFriend.CommID{FromUserID: userID, ToUserID: needNotifiedUserID, OpUserID: userID, OperationID: operationID}
friendNotification(&commID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) friendNotification(&commID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
} }

@ -416,8 +416,6 @@ func MemberQuitNotification(req *pbGroup.QuitGroupReq) {
} }
groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID) groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID)
// groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, "", req.OpUserID, req.OperationID)
} }
//message ApplicationProcessedTips{ //message ApplicationProcessedTips{

@ -171,10 +171,12 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s
log.NewError(data.OperationID, errMsg) log.NewError(data.OperationID, errMsg)
return false, 201, errMsg, nil return false, 201, errMsg, nil
} }
if !token_verify.IsManagerUserID(data.MsgData.SendID) { if token_verify.IsManagerUserID(data.MsgData.SendID) {
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { return true, 0, "", userIDList
return true, 0, "", userIDList }
} if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
return true, 0, "", userIDList
} else {
if !utils.IsContain(data.MsgData.SendID, userIDList) { if !utils.IsContain(data.MsgData.SendID, userIDList) {
//return returnMsg(&replay, pb, 202, "you are not in group", "", 0) //return returnMsg(&replay, pb, 202, "you are not in group", "", 0)
return false, 202, "you are not in group", nil return false, 202, "you are not in group", nil
@ -232,10 +234,12 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s
log.NewError(data.OperationID, errMsg) log.NewError(data.OperationID, errMsg)
return false, 201, errMsg, nil return false, 201, errMsg, nil
} }
if !token_verify.IsManagerUserID(data.MsgData.SendID) { if token_verify.IsManagerUserID(data.MsgData.SendID) {
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { return true, 0, "", userIDList
return true, 0, "", userIDList }
} if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
return true, 0, "", userIDList
} else {
if !utils.IsContain(data.MsgData.SendID, userIDList) { if !utils.IsContain(data.MsgData.SendID, userIDList) {
//return returnMsg(&replay, pb, 202, "you are not in group", "", 0) //return returnMsg(&replay, pb, 202, "you are not in group", "", 0)
return false, 202, "you are not in group", nil return false, 202, "you are not in group", nil

@ -450,7 +450,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
log.NewError(req.OperationID, "GetFriendList failed ", err.Error(), newReq) log.NewError(req.OperationID, "GetFriendList failed ", err.Error(), newReq)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
} }
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, req.OpUserID) chat.UserInfoUpdatedNotification(req.OperationID, req.OpUserID, req.UserInfo.UserID)
log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID) log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID)
if req.UserInfo.FaceURL != "" { if req.UserInfo.FaceURL != "" {
s.SyncJoinedGroupMemberFaceURL(req.UserInfo.UserID, req.UserInfo.FaceURL, req.OperationID, req.OpUserID) s.SyncJoinedGroupMemberFaceURL(req.UserInfo.UserID, req.UserInfo.FaceURL, req.OperationID, req.OpUserID)

@ -43,6 +43,7 @@ type Conversation struct {
DraftTextTime int64 `json:"draftTextTime"` DraftTextTime int64 `json:"draftTextTime"`
IsPinned bool `json:"isPinned" binding:"omitempty"` IsPinned bool `json:"isPinned" binding:"omitempty"`
IsPrivateChat bool `json:"isPrivateChat"` IsPrivateChat bool `json:"isPrivateChat"`
BurnDuration int32 `json:"burnDuration"`
GroupAtType int32 `json:"groupAtType"` GroupAtType int32 `json:"groupAtType"`
IsNotInGroup bool `json:"isNotInGroup"` IsNotInGroup bool `json:"isNotInGroup"`
UpdateUnreadCountTime int64 `json:"updateUnreadCountTime"` UpdateUnreadCountTime int64 `json:"updateUnreadCountTime"`

@ -1,12 +1,14 @@
package call_back_struct package call_back_struct
import ( import (
"Open_IM/pkg/proto/group"
commonPb "Open_IM/pkg/proto/sdk_ws" commonPb "Open_IM/pkg/proto/sdk_ws"
) )
type CallbackBeforeCreateGroupReq struct { type CallbackBeforeCreateGroupReq struct {
CallbackCommand string `json:"callbackCommand"` CallbackCommand string `json:"callbackCommand"`
commonPb.GroupInfo commonPb.GroupInfo
InitMemberList []*group.GroupAddMemberInfo `json:"initMemberList"`
} }
type CallbackBeforeCreateGroupResp struct { type CallbackBeforeCreateGroupResp struct {
@ -25,3 +27,20 @@ type CallbackBeforeCreateGroupResp struct {
LookMemberInfo *int32 `json:"lookMemberInfo"` LookMemberInfo *int32 `json:"lookMemberInfo"`
ApplyMemberFriend *int32 `json:"applyMemberFriend"` ApplyMemberFriend *int32 `json:"applyMemberFriend"`
} }
type CallbackBeforeMemberJoinGroupReq struct {
CallbackCommand string `json:"callbackCommand"`
GroupID string `json:"groupID"`
UserID string `json:"userID"`
Ex string `json:"ex"`
GroupEx string `json:"groupEx"`
}
type CallbackBeforeMemberJoinGroupResp struct {
*CommonCallbackResp
NickName *string `json:"nickName"`
FaceURL *string `json:"faceURL"`
RoleLevel *int32 `json:"roleLevel"`
MuteEndTime *int64 `json:"muteEndTime"`
Ex *string `json:"ex"`
}

@ -291,6 +291,7 @@ type config struct {
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"` CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`
CallbackBeforeAddFriend callBackConfig `yaml:"callbackBeforeAddFriend"` CallbackBeforeAddFriend callBackConfig `yaml:"callbackBeforeAddFriend"`
CallbackBeforeCreateGroup callBackConfig `yaml:"callbackBeforeCreateGroup"` CallbackBeforeCreateGroup callBackConfig `yaml:"callbackBeforeCreateGroup"`
CallbackBeforeMemberJoinGroup callBackConfig `yaml:"callbackBeforeMemberJoinGroup"`
} `yaml:"callback"` } `yaml:"callback"`
Notification struct { Notification struct {
///////////////////////group///////////////////////////// ///////////////////////group/////////////////////////////

@ -196,19 +196,20 @@ const (
VerificationCodeForResetSuffix = "_forReset" VerificationCodeForResetSuffix = "_forReset"
//callbackCommand //callbackCommand
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand" CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand" CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand" CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand" CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
CallbackMsgModifyCommand = "callbackMsgModifyCommand" CallbackMsgModifyCommand = "callbackMsgModifyCommand"
CallbackUserOnlineCommand = "callbackUserOnlineCommand" CallbackUserOnlineCommand = "callbackUserOnlineCommand"
CallbackUserOfflineCommand = "callbackUserOfflineCommand" CallbackUserOfflineCommand = "callbackUserOfflineCommand"
CallbackUserKickOffCommand = "callbackUserKickOffCommand" CallbackUserKickOffCommand = "callbackUserKickOffCommand"
CallbackOfflinePushCommand = "callbackOfflinePushCommand" CallbackOfflinePushCommand = "callbackOfflinePushCommand"
CallbackOnlinePushCommand = "callbackOnlinePushCommand" CallbackOnlinePushCommand = "callbackOnlinePushCommand"
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand" CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand" CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroup" CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand"
//callback actionCode //callback actionCode
ActionAllow = 0 ActionAllow = 0
@ -275,6 +276,7 @@ const (
FieldIsNotInGroup = 6 FieldIsNotInGroup = 6
FieldEx = 7 FieldEx = 7
FieldUnread = 8 FieldUnread = 8
FieldBurnDuration = 9
) )
const ( const (

@ -263,6 +263,7 @@ type Conversation struct {
DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"` DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"`
IsPinned bool `gorm:"column:is_pinned" json:"isPinned"` IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"` IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"` GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
IsNotInGroup bool `gorm:"column:is_not_in_group" json:"isNotInGroup"` IsNotInGroup bool `gorm:"column:is_not_in_group" json:"isNotInGroup"`
UpdateUnreadCountTime int64 `gorm:"column:update_unread_count_time" json:"updateUnreadCountTime"` UpdateUnreadCountTime int64 `gorm:"column:update_unread_count_time" json:"updateUnreadCountTime"`

@ -11,7 +11,7 @@ func SetConversation(conversation db.Conversation) (bool, error) {
newConversation := conversation newConversation := conversation
if db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 { if db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 {
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create") log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create")
return isUpdate, db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(conversation).Error return isUpdate, db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(&conversation).Error
// if exist, then update record // if exist, then update record
} else { } else {
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update") log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
@ -23,7 +23,7 @@ func SetConversation(conversation db.Conversation) (bool, error) {
} }
} }
func SetOneConversation(conversation db.Conversation) error { func SetOneConversation(conversation db.Conversation) error {
return db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(conversation).Error return db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(&conversation).Error
} }
@ -31,7 +31,7 @@ func PeerUserSetConversation(conversation db.Conversation) error {
newConversation := conversation newConversation := conversation
if db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 { if db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 {
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create") log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create")
return db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(conversation).Error return db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(&conversation).Error
// if exist, then update record // if exist, then update record
} }
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update") log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
@ -46,7 +46,7 @@ func SetRecvMsgOpt(conversation db.Conversation) (bool, error) {
newConversation := conversation newConversation := conversation
if db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 { if db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 {
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create") log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create")
return isUpdate, db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(conversation).Error return isUpdate, db.DB.MysqlDB.DefaultGormDB().Model(&db.Conversation{}).Create(&conversation).Error
// if exist, then update record // if exist, then update record
} else { } else {
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update") log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")

@ -1,587 +1,376 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.15.5
// source: conversation/conversation.proto // source: conversation/conversation.proto
package conversation package conversation // import "Open_IM/pkg/proto/conversation"
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import ( import (
context "context" context "golang.org/x/net/context"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
) )
const ( // Reference imports to suppress errors if they are not otherwise used.
// Verify that this generated code is sufficiently up-to-date. var _ = proto.Marshal
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) var _ = fmt.Errorf
// Verify that runtime/protoimpl is sufficiently up-to-date. var _ = math.Inf
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CommonResp struct { // This is a compile-time assertion to ensure that this generated file
state protoimpl.MessageState // is compatible with the proto package it is being compiled against.
sizeCache protoimpl.SizeCache // A compilation error at this line likely means your copy of the
unknownFields protoimpl.UnknownFields // proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
ErrCode int32 `protobuf:"varint,1,opt,name=errCode,proto3" json:"errCode,omitempty"` type CommonResp struct {
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg,proto3" json:"errMsg,omitempty"` ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (x *CommonResp) Reset() { func (m *CommonResp) Reset() { *m = CommonResp{} }
*x = CommonResp{} func (m *CommonResp) String() string { return proto.CompactTextString(m) }
if protoimpl.UnsafeEnabled { func (*CommonResp) ProtoMessage() {}
mi := &file_conversation_conversation_proto_msgTypes[0] func (*CommonResp) Descriptor() ([]byte, []int) {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) return fileDescriptor_conversation_7438d6c35155b4e4, []int{0}
ms.StoreMessageInfo(mi)
}
} }
func (m *CommonResp) XXX_Unmarshal(b []byte) error {
func (x *CommonResp) String() string { return xxx_messageInfo_CommonResp.Unmarshal(m, b)
return protoimpl.X.MessageStringOf(x)
} }
func (m *CommonResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (*CommonResp) ProtoMessage() {} return xxx_messageInfo_CommonResp.Marshal(b, m, deterministic)
func (x *CommonResp) ProtoReflect() protoreflect.Message {
mi := &file_conversation_conversation_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
} }
func (dst *CommonResp) XXX_Merge(src proto.Message) {
// Deprecated: Use CommonResp.ProtoReflect.Descriptor instead. xxx_messageInfo_CommonResp.Merge(dst, src)
func (*CommonResp) Descriptor() ([]byte, []int) { }
return file_conversation_conversation_proto_rawDescGZIP(), []int{0} func (m *CommonResp) XXX_Size() int {
return xxx_messageInfo_CommonResp.Size(m)
} }
func (m *CommonResp) XXX_DiscardUnknown() {
xxx_messageInfo_CommonResp.DiscardUnknown(m)
}
var xxx_messageInfo_CommonResp proto.InternalMessageInfo
func (x *CommonResp) GetErrCode() int32 { func (m *CommonResp) GetErrCode() int32 {
if x != nil { if m != nil {
return x.ErrCode return m.ErrCode
} }
return 0 return 0
} }
func (x *CommonResp) GetErrMsg() string { func (m *CommonResp) GetErrMsg() string {
if x != nil { if m != nil {
return x.ErrMsg return m.ErrMsg
} }
return "" return ""
} }
type Conversation struct { type Conversation struct {
state protoimpl.MessageState OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID" json:"ownerUserID,omitempty"`
sizeCache protoimpl.SizeCache ConversationID string `protobuf:"bytes,2,opt,name=conversationID" json:"conversationID,omitempty"`
unknownFields protoimpl.UnknownFields RecvMsgOpt int32 `protobuf:"varint,3,opt,name=recvMsgOpt" json:"recvMsgOpt,omitempty"`
ConversationType int32 `protobuf:"varint,4,opt,name=conversationType" json:"conversationType,omitempty"`
OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID,proto3" json:"ownerUserID,omitempty"` UserID string `protobuf:"bytes,5,opt,name=userID" json:"userID,omitempty"`
ConversationID string `protobuf:"bytes,2,opt,name=conversationID,proto3" json:"conversationID,omitempty"` GroupID string `protobuf:"bytes,6,opt,name=groupID" json:"groupID,omitempty"`
RecvMsgOpt int32 `protobuf:"varint,3,opt,name=recvMsgOpt,proto3" json:"recvMsgOpt,omitempty"` UnreadCount int32 `protobuf:"varint,7,opt,name=unreadCount" json:"unreadCount,omitempty"`
ConversationType int32 `protobuf:"varint,4,opt,name=conversationType,proto3" json:"conversationType,omitempty"` DraftTextTime int64 `protobuf:"varint,8,opt,name=draftTextTime" json:"draftTextTime,omitempty"`
UserID string `protobuf:"bytes,5,opt,name=userID,proto3" json:"userID,omitempty"` IsPinned bool `protobuf:"varint,9,opt,name=isPinned" json:"isPinned,omitempty"`
GroupID string `protobuf:"bytes,6,opt,name=groupID,proto3" json:"groupID,omitempty"` AttachedInfo string `protobuf:"bytes,10,opt,name=attachedInfo" json:"attachedInfo,omitempty"`
UnreadCount int32 `protobuf:"varint,7,opt,name=unreadCount,proto3" json:"unreadCount,omitempty"` IsPrivateChat bool `protobuf:"varint,11,opt,name=isPrivateChat" json:"isPrivateChat,omitempty"`
DraftTextTime int64 `protobuf:"varint,8,opt,name=draftTextTime,proto3" json:"draftTextTime,omitempty"` GroupAtType int32 `protobuf:"varint,12,opt,name=groupAtType" json:"groupAtType,omitempty"`
IsPinned bool `protobuf:"varint,9,opt,name=isPinned,proto3" json:"isPinned,omitempty"` IsNotInGroup bool `protobuf:"varint,13,opt,name=isNotInGroup" json:"isNotInGroup,omitempty"`
AttachedInfo string `protobuf:"bytes,10,opt,name=attachedInfo,proto3" json:"attachedInfo,omitempty"` Ex string `protobuf:"bytes,14,opt,name=ex" json:"ex,omitempty"`
IsPrivateChat bool `protobuf:"varint,11,opt,name=isPrivateChat,proto3" json:"isPrivateChat,omitempty"` UpdateUnreadCountTime int64 `protobuf:"varint,15,opt,name=updateUnreadCountTime" json:"updateUnreadCountTime,omitempty"`
GroupAtType int32 `protobuf:"varint,12,opt,name=groupAtType,proto3" json:"groupAtType,omitempty"` BurnDuration int32 `protobuf:"varint,16,opt,name=burnDuration" json:"burnDuration,omitempty"`
IsNotInGroup bool `protobuf:"varint,13,opt,name=isNotInGroup,proto3" json:"isNotInGroup,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
Ex string `protobuf:"bytes,14,opt,name=ex,proto3" json:"ex,omitempty"` XXX_unrecognized []byte `json:"-"`
UpdateUnreadCountTime int64 `protobuf:"varint,15,opt,name=updateUnreadCountTime,proto3" json:"updateUnreadCountTime,omitempty"` XXX_sizecache int32 `json:"-"`
} }
func (x *Conversation) Reset() { func (m *Conversation) Reset() { *m = Conversation{} }
*x = Conversation{} func (m *Conversation) String() string { return proto.CompactTextString(m) }
if protoimpl.UnsafeEnabled { func (*Conversation) ProtoMessage() {}
mi := &file_conversation_conversation_proto_msgTypes[1] func (*Conversation) Descriptor() ([]byte, []int) {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) return fileDescriptor_conversation_7438d6c35155b4e4, []int{1}
ms.StoreMessageInfo(mi)
}
} }
func (m *Conversation) XXX_Unmarshal(b []byte) error {
func (x *Conversation) String() string { return xxx_messageInfo_Conversation.Unmarshal(m, b)
return protoimpl.X.MessageStringOf(x)
} }
func (m *Conversation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (*Conversation) ProtoMessage() {} return xxx_messageInfo_Conversation.Marshal(b, m, deterministic)
func (x *Conversation) ProtoReflect() protoreflect.Message {
mi := &file_conversation_conversation_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
} }
func (dst *Conversation) XXX_Merge(src proto.Message) {
// Deprecated: Use Conversation.ProtoReflect.Descriptor instead. xxx_messageInfo_Conversation.Merge(dst, src)
func (*Conversation) Descriptor() ([]byte, []int) { }
return file_conversation_conversation_proto_rawDescGZIP(), []int{1} func (m *Conversation) XXX_Size() int {
return xxx_messageInfo_Conversation.Size(m)
}
func (m *Conversation) XXX_DiscardUnknown() {
xxx_messageInfo_Conversation.DiscardUnknown(m)
} }
func (x *Conversation) GetOwnerUserID() string { var xxx_messageInfo_Conversation proto.InternalMessageInfo
if x != nil {
return x.OwnerUserID func (m *Conversation) GetOwnerUserID() string {
if m != nil {
return m.OwnerUserID
} }
return "" return ""
} }
func (x *Conversation) GetConversationID() string { func (m *Conversation) GetConversationID() string {
if x != nil { if m != nil {
return x.ConversationID return m.ConversationID
} }
return "" return ""
} }
func (x *Conversation) GetRecvMsgOpt() int32 { func (m *Conversation) GetRecvMsgOpt() int32 {
if x != nil { if m != nil {
return x.RecvMsgOpt return m.RecvMsgOpt
} }
return 0 return 0
} }
func (x *Conversation) GetConversationType() int32 { func (m *Conversation) GetConversationType() int32 {
if x != nil { if m != nil {
return x.ConversationType return m.ConversationType
} }
return 0 return 0
} }
func (x *Conversation) GetUserID() string { func (m *Conversation) GetUserID() string {
if x != nil { if m != nil {
return x.UserID return m.UserID
} }
return "" return ""
} }
func (x *Conversation) GetGroupID() string { func (m *Conversation) GetGroupID() string {
if x != nil { if m != nil {
return x.GroupID return m.GroupID
} }
return "" return ""
} }
func (x *Conversation) GetUnreadCount() int32 { func (m *Conversation) GetUnreadCount() int32 {
if x != nil { if m != nil {
return x.UnreadCount return m.UnreadCount
} }
return 0 return 0
} }
func (x *Conversation) GetDraftTextTime() int64 { func (m *Conversation) GetDraftTextTime() int64 {
if x != nil { if m != nil {
return x.DraftTextTime return m.DraftTextTime
} }
return 0 return 0
} }
func (x *Conversation) GetIsPinned() bool { func (m *Conversation) GetIsPinned() bool {
if x != nil { if m != nil {
return x.IsPinned return m.IsPinned
} }
return false return false
} }
func (x *Conversation) GetAttachedInfo() string { func (m *Conversation) GetAttachedInfo() string {
if x != nil { if m != nil {
return x.AttachedInfo return m.AttachedInfo
} }
return "" return ""
} }
func (x *Conversation) GetIsPrivateChat() bool { func (m *Conversation) GetIsPrivateChat() bool {
if x != nil { if m != nil {
return x.IsPrivateChat return m.IsPrivateChat
} }
return false return false
} }
func (x *Conversation) GetGroupAtType() int32 { func (m *Conversation) GetGroupAtType() int32 {
if x != nil { if m != nil {
return x.GroupAtType return m.GroupAtType
} }
return 0 return 0
} }
func (x *Conversation) GetIsNotInGroup() bool { func (m *Conversation) GetIsNotInGroup() bool {
if x != nil { if m != nil {
return x.IsNotInGroup return m.IsNotInGroup
} }
return false return false
} }
func (x *Conversation) GetEx() string { func (m *Conversation) GetEx() string {
if x != nil { if m != nil {
return x.Ex return m.Ex
} }
return "" return ""
} }
func (x *Conversation) GetUpdateUnreadCountTime() int64 { func (m *Conversation) GetUpdateUnreadCountTime() int64 {
if x != nil { if m != nil {
return x.UpdateUnreadCountTime return m.UpdateUnreadCountTime
} }
return 0 return 0
} }
type ModifyConversationFieldReq struct { func (m *Conversation) GetBurnDuration() int32 {
state protoimpl.MessageState if m != nil {
sizeCache protoimpl.SizeCache return m.BurnDuration
unknownFields protoimpl.UnknownFields
Conversation *Conversation `protobuf:"bytes,1,opt,name=conversation,proto3" json:"conversation,omitempty"`
FieldType int32 `protobuf:"varint,2,opt,name=fieldType,proto3" json:"fieldType,omitempty"`
UserIDList []string `protobuf:"bytes,3,rep,name=userIDList,proto3" json:"userIDList,omitempty"`
OperationID string `protobuf:"bytes,4,opt,name=operationID,proto3" json:"operationID,omitempty"`
}
func (x *ModifyConversationFieldReq) Reset() {
*x = ModifyConversationFieldReq{}
if protoimpl.UnsafeEnabled {
mi := &file_conversation_conversation_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
} }
return 0
} }
func (x *ModifyConversationFieldReq) String() string { type ModifyConversationFieldReq struct {
return protoimpl.X.MessageStringOf(x) Conversation *Conversation `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"`
FieldType int32 `protobuf:"varint,2,opt,name=fieldType" json:"fieldType,omitempty"`
UserIDList []string `protobuf:"bytes,3,rep,name=userIDList" json:"userIDList,omitempty"`
OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ModifyConversationFieldReq) Reset() { *m = ModifyConversationFieldReq{} }
func (m *ModifyConversationFieldReq) String() string { return proto.CompactTextString(m) }
func (*ModifyConversationFieldReq) ProtoMessage() {}
func (*ModifyConversationFieldReq) Descriptor() ([]byte, []int) {
return fileDescriptor_conversation_7438d6c35155b4e4, []int{2}
} }
func (m *ModifyConversationFieldReq) XXX_Unmarshal(b []byte) error {
func (*ModifyConversationFieldReq) ProtoMessage() {} return xxx_messageInfo_ModifyConversationFieldReq.Unmarshal(m, b)
func (x *ModifyConversationFieldReq) ProtoReflect() protoreflect.Message {
mi := &file_conversation_conversation_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
} }
func (m *ModifyConversationFieldReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
// Deprecated: Use ModifyConversationFieldReq.ProtoReflect.Descriptor instead. return xxx_messageInfo_ModifyConversationFieldReq.Marshal(b, m, deterministic)
func (*ModifyConversationFieldReq) Descriptor() ([]byte, []int) { }
return file_conversation_conversation_proto_rawDescGZIP(), []int{2} func (dst *ModifyConversationFieldReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_ModifyConversationFieldReq.Merge(dst, src)
}
func (m *ModifyConversationFieldReq) XXX_Size() int {
return xxx_messageInfo_ModifyConversationFieldReq.Size(m)
}
func (m *ModifyConversationFieldReq) XXX_DiscardUnknown() {
xxx_messageInfo_ModifyConversationFieldReq.DiscardUnknown(m)
} }
func (x *ModifyConversationFieldReq) GetConversation() *Conversation { var xxx_messageInfo_ModifyConversationFieldReq proto.InternalMessageInfo
if x != nil {
return x.Conversation func (m *ModifyConversationFieldReq) GetConversation() *Conversation {
if m != nil {
return m.Conversation
} }
return nil return nil
} }
func (x *ModifyConversationFieldReq) GetFieldType() int32 { func (m *ModifyConversationFieldReq) GetFieldType() int32 {
if x != nil { if m != nil {
return x.FieldType return m.FieldType
} }
return 0 return 0
} }
func (x *ModifyConversationFieldReq) GetUserIDList() []string { func (m *ModifyConversationFieldReq) GetUserIDList() []string {
if x != nil { if m != nil {
return x.UserIDList return m.UserIDList
} }
return nil return nil
} }
func (x *ModifyConversationFieldReq) GetOperationID() string { func (m *ModifyConversationFieldReq) GetOperationID() string {
if x != nil { if m != nil {
return x.OperationID return m.OperationID
} }
return "" return ""
} }
type ModifyConversationFieldResp struct { type ModifyConversationFieldResp struct {
state protoimpl.MessageState CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
sizeCache protoimpl.SizeCache XXX_NoUnkeyedLiteral struct{} `json:"-"`
unknownFields protoimpl.UnknownFields XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp,proto3" json:"commonResp,omitempty"`
} }
func (x *ModifyConversationFieldResp) Reset() { func (m *ModifyConversationFieldResp) Reset() { *m = ModifyConversationFieldResp{} }
*x = ModifyConversationFieldResp{} func (m *ModifyConversationFieldResp) String() string { return proto.CompactTextString(m) }
if protoimpl.UnsafeEnabled { func (*ModifyConversationFieldResp) ProtoMessage() {}
mi := &file_conversation_conversation_proto_msgTypes[3] func (*ModifyConversationFieldResp) Descriptor() ([]byte, []int) {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) return fileDescriptor_conversation_7438d6c35155b4e4, []int{3}
ms.StoreMessageInfo(mi)
}
} }
func (m *ModifyConversationFieldResp) XXX_Unmarshal(b []byte) error {
func (x *ModifyConversationFieldResp) String() string { return xxx_messageInfo_ModifyConversationFieldResp.Unmarshal(m, b)
return protoimpl.X.MessageStringOf(x)
} }
func (m *ModifyConversationFieldResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (*ModifyConversationFieldResp) ProtoMessage() {} return xxx_messageInfo_ModifyConversationFieldResp.Marshal(b, m, deterministic)
func (x *ModifyConversationFieldResp) ProtoReflect() protoreflect.Message {
mi := &file_conversation_conversation_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
} }
func (dst *ModifyConversationFieldResp) XXX_Merge(src proto.Message) {
// Deprecated: Use ModifyConversationFieldResp.ProtoReflect.Descriptor instead. xxx_messageInfo_ModifyConversationFieldResp.Merge(dst, src)
func (*ModifyConversationFieldResp) Descriptor() ([]byte, []int) { }
return file_conversation_conversation_proto_rawDescGZIP(), []int{3} func (m *ModifyConversationFieldResp) XXX_Size() int {
return xxx_messageInfo_ModifyConversationFieldResp.Size(m)
}
func (m *ModifyConversationFieldResp) XXX_DiscardUnknown() {
xxx_messageInfo_ModifyConversationFieldResp.DiscardUnknown(m)
} }
func (x *ModifyConversationFieldResp) GetCommonResp() *CommonResp { var xxx_messageInfo_ModifyConversationFieldResp proto.InternalMessageInfo
if x != nil {
return x.CommonResp func (m *ModifyConversationFieldResp) GetCommonResp() *CommonResp {
if m != nil {
return m.CommonResp
} }
return nil return nil
} }
var File_conversation_conversation_proto protoreflect.FileDescriptor func init() {
proto.RegisterType((*CommonResp)(nil), "conversation.CommonResp")
var file_conversation_conversation_proto_rawDesc = []byte{ proto.RegisterType((*Conversation)(nil), "conversation.Conversation")
0x0a, 0x1f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x63, proto.RegisterType((*ModifyConversationFieldReq)(nil), "conversation.ModifyConversationFieldReq")
0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, proto.RegisterType((*ModifyConversationFieldResp)(nil), "conversation.ModifyConversationFieldResp")
0x6f, 0x12, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22,
0x3e, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a,
0x07, 0x65, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07,
0x65, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73,
0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x22,
0x90, 0x04, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x20, 0x0a, 0x0b, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72,
0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x76,
0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65,
0x63, 0x76, 0x4d, 0x73, 0x67, 0x4f, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
0x72, 0x65, 0x63, 0x76, 0x4d, 0x73, 0x67, 0x4f, 0x70, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f,
0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04,
0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x18,
0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x75, 0x6e, 0x72, 0x65,
0x61, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x75,
0x6e, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x72,
0x61, 0x66, 0x74, 0x54, 0x65, 0x78, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28,
0x03, 0x52, 0x0d, 0x64, 0x72, 0x61, 0x66, 0x74, 0x54, 0x65, 0x78, 0x74, 0x54, 0x69, 0x6d, 0x65,
0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x50, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01,
0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x50, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x12, 0x22, 0x0a, 0x0c,
0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0a, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0c, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x49, 0x6e, 0x66, 0x6f,
0x12, 0x24, 0x0a, 0x0d, 0x69, 0x73, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61,
0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x69, 0x73, 0x50, 0x72, 0x69, 0x76, 0x61,
0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x41,
0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x67, 0x72, 0x6f,
0x75, 0x70, 0x41, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x69, 0x73, 0x4e, 0x6f,
0x74, 0x49, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c,
0x69, 0x73, 0x4e, 0x6f, 0x74, 0x49, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x0e, 0x0a, 0x02,
0x65, 0x78, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x65, 0x78, 0x12, 0x34, 0x0a, 0x15,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x75, 0x6e,
0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x15, 0x75, 0x70, 0x64,
0x61, 0x74, 0x65, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x69,
0x6d, 0x65, 0x22, 0xbc, 0x01, 0x0a, 0x1a, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x6e,
0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x65,
0x71, 0x12, 0x3e, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72,
0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12,
0x1e, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20,
0x03, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x12,
0x20, 0x0a, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49,
0x44, 0x22, 0x57, 0x0a, 0x1b, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x6e, 0x76, 0x65,
0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x65, 0x73, 0x70,
0x12, 0x38, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x52, 0x0a,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x32, 0x7e, 0x0a, 0x0c, 0x63, 0x6f,
0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x6e, 0x0a, 0x17, 0x4d, 0x6f,
0x64, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x28, 0x2e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x6e, 0x76, 0x65,
0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x1a,
0x29, 0x2e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d,
0x6f, 0x64, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x65, 0x73, 0x70, 0x42, 0x2d, 0x5a, 0x2b, 0x4f, 0x70,
0x65, 0x6e, 0x5f, 0x49, 0x4d, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f,
0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x63, 0x6f, 0x6e,
0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
file_conversation_conversation_proto_rawDescOnce sync.Once
file_conversation_conversation_proto_rawDescData = file_conversation_conversation_proto_rawDesc
)
func file_conversation_conversation_proto_rawDescGZIP() []byte {
file_conversation_conversation_proto_rawDescOnce.Do(func() {
file_conversation_conversation_proto_rawDescData = protoimpl.X.CompressGZIP(file_conversation_conversation_proto_rawDescData)
})
return file_conversation_conversation_proto_rawDescData
}
var file_conversation_conversation_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_conversation_conversation_proto_goTypes = []interface{}{
(*CommonResp)(nil), // 0: conversation.CommonResp
(*Conversation)(nil), // 1: conversation.Conversation
(*ModifyConversationFieldReq)(nil), // 2: conversation.ModifyConversationFieldReq
(*ModifyConversationFieldResp)(nil), // 3: conversation.ModifyConversationFieldResp
}
var file_conversation_conversation_proto_depIdxs = []int32{
1, // 0: conversation.ModifyConversationFieldReq.conversation:type_name -> conversation.Conversation
0, // 1: conversation.ModifyConversationFieldResp.commonResp:type_name -> conversation.CommonResp
2, // 2: conversation.conversation.ModifyConversationField:input_type -> conversation.ModifyConversationFieldReq
3, // 3: conversation.conversation.ModifyConversationField:output_type -> conversation.ModifyConversationFieldResp
3, // [3:4] is the sub-list for method output_type
2, // [2:3] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_conversation_conversation_proto_init() }
func file_conversation_conversation_proto_init() {
if File_conversation_conversation_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_conversation_conversation_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommonResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conversation_conversation_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Conversation); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conversation_conversation_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ModifyConversationFieldReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conversation_conversation_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ModifyConversationFieldResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_conversation_conversation_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_conversation_conversation_proto_goTypes,
DependencyIndexes: file_conversation_conversation_proto_depIdxs,
MessageInfos: file_conversation_conversation_proto_msgTypes,
}.Build()
File_conversation_conversation_proto = out.File
file_conversation_conversation_proto_rawDesc = nil
file_conversation_conversation_proto_goTypes = nil
file_conversation_conversation_proto_depIdxs = nil
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ context.Context var _ context.Context
var _ grpc.ClientConnInterface var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file // This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against. // is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6 const _ = grpc.SupportPackageIsVersion4
// Client API for Conversation service
// ConversationClient is the client API for Conversation service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ConversationClient interface { type ConversationClient interface {
ModifyConversationField(ctx context.Context, in *ModifyConversationFieldReq, opts ...grpc.CallOption) (*ModifyConversationFieldResp, error) ModifyConversationField(ctx context.Context, in *ModifyConversationFieldReq, opts ...grpc.CallOption) (*ModifyConversationFieldResp, error)
} }
type conversationClient struct { type conversationClient struct {
cc grpc.ClientConnInterface cc *grpc.ClientConn
} }
func NewConversationClient(cc grpc.ClientConnInterface) ConversationClient { func NewConversationClient(cc *grpc.ClientConn) ConversationClient {
return &conversationClient{cc} return &conversationClient{cc}
} }
func (c *conversationClient) ModifyConversationField(ctx context.Context, in *ModifyConversationFieldReq, opts ...grpc.CallOption) (*ModifyConversationFieldResp, error) { func (c *conversationClient) ModifyConversationField(ctx context.Context, in *ModifyConversationFieldReq, opts ...grpc.CallOption) (*ModifyConversationFieldResp, error) {
out := new(ModifyConversationFieldResp) out := new(ModifyConversationFieldResp)
err := c.cc.Invoke(ctx, "/conversation.conversation/ModifyConversationField", in, out, opts...) err := grpc.Invoke(ctx, "/conversation.conversation/ModifyConversationField", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
// ConversationServer is the server API for Conversation service. // Server API for Conversation service
type ConversationServer interface { type ConversationServer interface {
ModifyConversationField(context.Context, *ModifyConversationFieldReq) (*ModifyConversationFieldResp, error) ModifyConversationField(context.Context, *ModifyConversationFieldReq) (*ModifyConversationFieldResp, error)
} }
// UnimplementedConversationServer can be embedded to have forward compatible implementations.
type UnimplementedConversationServer struct {
}
func (*UnimplementedConversationServer) ModifyConversationField(context.Context, *ModifyConversationFieldReq) (*ModifyConversationFieldResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyConversationField not implemented")
}
func RegisterConversationServer(s *grpc.Server, srv ConversationServer) { func RegisterConversationServer(s *grpc.Server, srv ConversationServer) {
s.RegisterService(&_Conversation_serviceDesc, srv) s.RegisterService(&_Conversation_serviceDesc, srv)
} }
@ -616,3 +405,44 @@ var _Conversation_serviceDesc = grpc.ServiceDesc{
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "conversation/conversation.proto", Metadata: "conversation/conversation.proto",
} }
func init() {
proto.RegisterFile("conversation/conversation.proto", fileDescriptor_conversation_7438d6c35155b4e4)
}
var fileDescriptor_conversation_7438d6c35155b4e4 = []byte{
// 520 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xd1, 0x6b, 0x13, 0x41,
0x10, 0xc6, 0xb9, 0xb4, 0x4d, 0x93, 0x49, 0x1a, 0xcb, 0x82, 0xba, 0x44, 0xd1, 0x10, 0x44, 0x4e,
0xc5, 0x06, 0xaa, 0x0f, 0x82, 0x50, 0xd0, 0x04, 0xe5, 0xc0, 0xd8, 0x72, 0xa4, 0x08, 0xbe, 0xc8,
0x35, 0x37, 0x49, 0x0f, 0xcd, 0xee, 0xba, 0xbb, 0x17, 0xd3, 0x17, 0xff, 0x2a, 0x1f, 0xfd, 0xe3,
0x64, 0x27, 0x49, 0xb3, 0x5b, 0x0d, 0xf8, 0x38, 0xbf, 0x9d, 0xfb, 0xe6, 0x9b, 0xcd, 0x97, 0x85,
0x87, 0x63, 0x29, 0xe6, 0xa8, 0x4d, 0x66, 0x0b, 0x29, 0x7a, 0x7e, 0x71, 0xa4, 0xb4, 0xb4, 0x92,
0x35, 0x7d, 0xd6, 0x3d, 0x01, 0xe8, 0xcb, 0xd9, 0x4c, 0x8a, 0x14, 0x8d, 0x62, 0x1c, 0xf6, 0x51,
0xeb, 0xbe, 0xcc, 0x91, 0x47, 0x9d, 0x28, 0xde, 0x4b, 0xd7, 0x25, 0xbb, 0x03, 0x55, 0xd4, 0x7a,
0x68, 0xa6, 0xbc, 0xd2, 0x89, 0xe2, 0x7a, 0xba, 0xaa, 0xba, 0xbf, 0x76, 0xa1, 0xd9, 0xf7, 0x04,
0x59, 0x07, 0x1a, 0xf2, 0x87, 0x40, 0x7d, 0x6e, 0x50, 0x27, 0x03, 0x92, 0xa9, 0xa7, 0x3e, 0x62,
0x8f, 0xa1, 0xe5, 0x5b, 0x48, 0x06, 0x2b, 0xc9, 0x1b, 0x94, 0x3d, 0x00, 0xd0, 0x38, 0x9e, 0x0f,
0xcd, 0xf4, 0x54, 0x59, 0xbe, 0x43, 0x7e, 0x3c, 0xc2, 0x9e, 0xc2, 0xa1, 0xff, 0xc5, 0xe8, 0x4a,
0x21, 0xdf, 0xa5, 0xae, 0xbf, 0xb8, 0xb3, 0x5f, 0x2e, 0x0d, 0xed, 0x2d, 0xed, 0x2f, 0x2b, 0xb7,
0xf0, 0x54, 0xcb, 0x52, 0x25, 0x03, 0x5e, 0xa5, 0x83, 0x75, 0xe9, 0xf6, 0x28, 0x85, 0xc6, 0x2c,
0xef, 0xcb, 0x52, 0x58, 0xbe, 0x4f, 0xc2, 0x3e, 0x62, 0x8f, 0xe0, 0x20, 0xd7, 0xd9, 0xc4, 0x8e,
0x70, 0x61, 0x47, 0xc5, 0x0c, 0x79, 0xad, 0x13, 0xc5, 0x3b, 0x69, 0x08, 0x59, 0x1b, 0x6a, 0x85,
0x39, 0x2b, 0x84, 0xc0, 0x9c, 0xd7, 0x3b, 0x51, 0x5c, 0x4b, 0xaf, 0x6b, 0xd6, 0x85, 0x66, 0x66,
0x6d, 0x36, 0xbe, 0xc4, 0x3c, 0x11, 0x13, 0xc9, 0x81, 0x2c, 0x04, 0xcc, 0x4d, 0x29, 0xcc, 0x99,
0x2e, 0xe6, 0x99, 0xc5, 0xfe, 0x65, 0x66, 0x79, 0x83, 0x44, 0x42, 0xe8, 0xdc, 0x92, 0xf1, 0x37,
0x96, 0xae, 0xa1, 0xb9, 0x74, 0xeb, 0x21, 0x37, 0xab, 0x30, 0x1f, 0xa5, 0x4d, 0xc4, 0x7b, 0x47,
0xf9, 0x01, 0xc9, 0x04, 0x8c, 0xb5, 0xa0, 0x82, 0x0b, 0xde, 0x22, 0x17, 0x15, 0x5c, 0xb0, 0x97,
0x70, 0xbb, 0x54, 0x79, 0x66, 0xf1, 0x7c, 0xb3, 0x36, 0x6d, 0x7a, 0x8b, 0x36, 0xfd, 0xf7, 0xa1,
0x9b, 0x74, 0x51, 0x6a, 0x31, 0x28, 0x35, 0xdd, 0x3f, 0x3f, 0x24, 0x33, 0x01, 0xeb, 0xfe, 0x8e,
0xa0, 0x3d, 0x94, 0x79, 0x31, 0xb9, 0xf2, 0xc3, 0xf3, 0xae, 0xc0, 0x6f, 0x79, 0x8a, 0xdf, 0xd9,
0x09, 0x04, 0x29, 0xa5, 0x14, 0x35, 0x8e, 0xdb, 0x47, 0x41, 0x9c, 0xfd, 0x2f, 0xd3, 0xa0, 0x9f,
0xdd, 0x87, 0xfa, 0xc4, 0x69, 0xd1, 0x65, 0x54, 0x68, 0xfe, 0x06, 0xb8, 0x60, 0x2d, 0x7f, 0xfe,
0x0f, 0x85, 0x71, 0xc1, 0xda, 0x89, 0xeb, 0xa9, 0x47, 0x28, 0xc2, 0x0a, 0xf5, 0x3a, 0x9d, 0xbb,
0xab, 0x08, 0x6f, 0x50, 0xf7, 0x13, 0xdc, 0xdb, 0xea, 0xde, 0x28, 0xf6, 0x0a, 0x60, 0x7c, 0xfd,
0xa7, 0x5a, 0x99, 0xe7, 0x37, 0xcd, 0xaf, 0xcf, 0x53, 0xaf, 0xf7, 0xf8, 0x67, 0xb8, 0x38, 0x13,
0x70, 0x77, 0xcb, 0x20, 0x16, 0x87, 0x82, 0xdb, 0x6f, 0xb3, 0xfd, 0xe4, 0x3f, 0x3b, 0x8d, 0x7a,
0xfb, 0xfc, 0xf3, 0xb3, 0x53, 0x85, 0xe2, 0x4b, 0x32, 0xec, 0xa9, 0xaf, 0xd3, 0x1e, 0xbd, 0x18,
0xc1, 0x23, 0xf2, 0xda, 0x2f, 0x2e, 0xaa, 0xd4, 0xf0, 0xe2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff,
0xb3, 0xd2, 0x40, 0x56, 0x75, 0x04, 0x00, 0x00,
}

@ -22,6 +22,7 @@ message Conversation{
bool isNotInGroup = 13; bool isNotInGroup = 13;
string ex = 14; string ex = 14;
int64 updateUnreadCountTime = 15; int64 updateUnreadCountTime = 15;
int32 burnDuration = 16;
} }
message ModifyConversationFieldReq{ message ModifyConversationFieldReq{

@ -2,14 +2,25 @@ package utils
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"errors"
"fmt" "fmt"
"math/rand" "math/rand"
"os" "os"
"path" "path"
"strconv"
"strings"
"time" "time"
) )
const (
BYTE = 1 << (10 * iota)
KILOBYTE
MEGABYTE
GIGABYTE
TERABYTE
PETABYTE
EXABYTE
)
// Determine whether the given path is a folder // Determine whether the given path is a folder
func IsDir(path string) bool { func IsDir(path string) bool {
s, err := os.Stat(path) s, err := os.Stat(path)
@ -39,39 +50,34 @@ func GetNewFileNameAndContentType(fileName string, fileType int) (string, string
return newName, contentType return newName, contentType
} }
func GetUploadAppNewName(appType int, version, fileName, yamlName string) (string, string, error) { func ByteSize(bytes uint64) string {
var newFileName, newYamlName = "_" + version + "_app", "_" + version + "_yaml" unit := ""
switch appType { value := float64(bytes)
case constant.IOSPlatformID: switch {
newFileName = constant.IOSPlatformStr + newFileName case bytes >= EXABYTE:
newYamlName = constant.IOSPlatformStr + newYamlName unit = "E"
case constant.AndroidPlatformID: value = value / EXABYTE
newFileName = constant.AndroidPlatformStr + newFileName case bytes >= PETABYTE:
newYamlName = constant.AndroidPlatformStr + newYamlName unit = "P"
case constant.WindowsPlatformID: value = value / PETABYTE
newFileName = constant.WindowsPlatformStr + newFileName case bytes >= TERABYTE:
newYamlName = constant.WindowsPlatformStr + newYamlName unit = "T"
case constant.OSXPlatformID: value = value / TERABYTE
newFileName = constant.OSXPlatformStr + newFileName case bytes >= GIGABYTE:
newYamlName = constant.OSXPlatformStr + newYamlName unit = "G"
case constant.WebPlatformID: value = value / GIGABYTE
newFileName = constant.WebPlatformStr + newFileName case bytes >= MEGABYTE:
newYamlName = constant.WebPlatformStr + newYamlName unit = "M"
case constant.MiniWebPlatformID: value = value / MEGABYTE
newFileName = constant.MiniWebPlatformStr + newFileName case bytes >= KILOBYTE:
newYamlName = constant.MiniWebPlatformStr + newYamlName unit = "K"
case constant.LinuxPlatformID: value = value / KILOBYTE
newFileName = constant.LinuxPlatformStr + newFileName case bytes >= BYTE:
newYamlName = constant.LinuxPlatformStr + newYamlName unit = "B"
default: case bytes == 0:
return "", "", errors.New("invalid app type") return "0"
}
suffixFile := path.Ext(fileName)
suffixYaml := path.Ext(yamlName)
newFileName = fmt.Sprintf("%s%s", newFileName, suffixFile)
newYamlName = fmt.Sprintf("%s%s", newYamlName, suffixYaml)
if yamlName == "" {
newYamlName = ""
} }
return newFileName, newYamlName, nil result := strconv.FormatFloat(value, 'f', 1, 64)
result = strings.TrimSuffix(result, ".0")
return result + unit
} }

Loading…
Cancel
Save