mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
superGroupMaxSeq
This commit is contained in:
parent
337d01008b
commit
a5ef78fd1e
@ -21,7 +21,6 @@ import (
|
||||
// @Tags 鉴权认证
|
||||
// @ID UserRegister
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UserRegisterReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID <br> ex为拓展字段 <br> gender为性别, 0为女, 1为男"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UserRegisterResp
|
||||
@ -90,7 +89,6 @@ func UserRegister(c *gin.Context) {
|
||||
// @Tags 鉴权认证
|
||||
// @ID UserToken
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UserTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UserTokenResp
|
||||
|
@ -232,7 +232,7 @@ func onboardingProcessNotification(operationID, userID, groupID, userName, faceU
|
||||
Content: []byte(welcomeString),
|
||||
MsgFrom: constant.UserMsgType,
|
||||
ContentType: constant.Text,
|
||||
SessionType: constant.GroupChatType,
|
||||
SessionType: constant.SuperGroupChatType,
|
||||
OperationID: operationID,
|
||||
SenderNickname: userName,
|
||||
SenderFaceURL: faceURL,
|
||||
|
@ -13,34 +13,26 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *open_im_sdk.GetMaxAnd
|
||||
log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String())
|
||||
resp := new(open_im_sdk.GetMaxAndMinSeqResp)
|
||||
m := make(map[string]*open_im_sdk.MaxAndMinSeq)
|
||||
//seq, err := model.GetBiggestSeqFromReceive(in.UserID)
|
||||
maxSeq, err1 := commonDB.DB.GetUserMaxSeq(in.UserID)
|
||||
//minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID)
|
||||
if err1 == nil {
|
||||
resp.MaxSeq = uint32(maxSeq)
|
||||
for _, v := range in.GroupIDList {
|
||||
x := new(open_im_sdk.MaxAndMinSeq)
|
||||
maxSeq, _ := commonDB.DB.GetUserMaxSeq(v)
|
||||
x.MaxSeq = uint32(maxSeq)
|
||||
m[v] = x
|
||||
}
|
||||
resp.GroupMaxAndMinSeq = m
|
||||
} else if err1 == go_redis.Nil {
|
||||
resp.MaxSeq = 0
|
||||
} else {
|
||||
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err1.Error())
|
||||
var maxSeq, minSeq uint64
|
||||
var err error
|
||||
maxSeq, err = commonDB.DB.GetUserMaxSeq(in.UserID)
|
||||
minSeq, err = commonDB.DB.GetUserMinSeq(in.UserID)
|
||||
if err != nil && err != go_redis.Nil {
|
||||
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err.Error())
|
||||
resp.ErrCode = 200
|
||||
resp.ErrMsg = "redis get err"
|
||||
return resp, nil
|
||||
}
|
||||
resp.MaxSeq = uint32(maxSeq)
|
||||
resp.MinSeq = uint32(minSeq)
|
||||
for _, groupID := range in.GroupIDList {
|
||||
x := new(open_im_sdk.MaxAndMinSeq)
|
||||
maxSeq, _ := commonDB.DB.GetGroupMaxSeq(groupID)
|
||||
minSeq, _ := commonDB.DB.GetGroupUserMinSeq(groupID, in.UserID)
|
||||
x.MaxSeq = uint32(maxSeq)
|
||||
x.MinSeq = uint32(minSeq)
|
||||
m[groupID] = x
|
||||
}
|
||||
//if err2 == nil {
|
||||
// resp.MinSeq = uint32(minSeq)
|
||||
//} else if err2 == redis.ErrNil {
|
||||
// resp.MinSeq = 0
|
||||
//} else {
|
||||
// log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err2.Error())
|
||||
// resp.ErrCode = 201
|
||||
// resp.ErrMsg = "redis get err"
|
||||
//}
|
||||
return resp, nil
|
||||
}
|
||||
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {
|
||||
|
@ -32,14 +32,9 @@ const (
|
||||
SignalListCache = "SIGNAL_LIST_CACHE:"
|
||||
GlobalMsgRecvOpt = "GLOBAL_MSG_RECV_OPT"
|
||||
groupUserMinSeq = "GROUP_USER_MIN_SEQ:"
|
||||
groupMaxSeq = "GROUP_MAX_SEQ"
|
||||
)
|
||||
|
||||
//func (d * DataBases)pubMessage(channel, msg string) {
|
||||
// d.rdb.Publish(context.Background(),channel,msg)
|
||||
//}
|
||||
//func (d * DataBases)pubMessage(channel, msg string) {
|
||||
// d.rdb.Publish(context.Background(),channel,msg)
|
||||
//}
|
||||
func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
|
||||
key := accountTempCode + account
|
||||
n, err := d.RDB.Exists(context.Background(), key).Result()
|
||||
@ -101,6 +96,23 @@ func (d *DataBases) GetGroupUserMinSeq(groupID, userID string) (uint64, error) {
|
||||
return uint64(utils.StringToInt(seq)), err
|
||||
}
|
||||
|
||||
func (d *DataBases) GetGroupMaxSeq(groupID string) (uint64, error) {
|
||||
key := groupMaxSeq + groupID
|
||||
seq, err := d.RDB.Get(context.Background(), key).Result()
|
||||
return uint64(utils.StringToInt(seq)), err
|
||||
}
|
||||
|
||||
func (d *DataBases) IncrGroupMaxSeq(groupID string) (uint64, error) {
|
||||
key := groupMaxSeq + groupID
|
||||
seq, err := d.RDB.Incr(context.Background(), key).Result()
|
||||
return uint64(seq), err
|
||||
}
|
||||
|
||||
func (d *DataBases) SetGroupMaxSeq(groupID string, maxSeq uint32) error {
|
||||
key := groupMaxSeq + groupID
|
||||
return d.RDB.Set(context.Background(), key, maxSeq, 0).Err()
|
||||
}
|
||||
|
||||
//Store userid and platform class to redis
|
||||
func (d *DataBases) AddTokenFlag(userID string, platformID int, token string, flag int) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user