mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 11:40:01 +08:00
Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release
This commit is contained in:
commit
029c020fe0
@ -138,12 +138,6 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
data = VideoElem{}
|
||||
case constant.File:
|
||||
data = FileElem{}
|
||||
//case constant.AtText:
|
||||
// data = AtElem{}
|
||||
//case constant.Merger:
|
||||
// data =
|
||||
//case constant.Card:
|
||||
//case constant.Location:
|
||||
case constant.Custom:
|
||||
data = CustomElem{}
|
||||
case constant.Revoke:
|
||||
@ -161,16 +155,16 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
//case constant.Typing:
|
||||
//case constant.Quote:
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
||||
return
|
||||
} else if err := validate.Struct(data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
|
||||
return
|
||||
}
|
||||
@ -178,12 +172,13 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||
log.NewError(params.OperationID, "parse token failed", err.Error(), token)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||
log.NewError(params.OperationID, "not authorized", token)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
|
||||
}
|
||||
@ -191,13 +186,13 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
case constant.SingleChatType:
|
||||
if len(params.RecvID) == 0 {
|
||||
log.NewError(params.OperationID, "recvID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
if len(params.GroupID) == 0 {
|
||||
log.NewError(params.OperationID, "groupID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -10,22 +10,23 @@ import (
|
||||
goRedis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const oldestList = 0
|
||||
const newestList = -1
|
||||
|
||||
func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) error {
|
||||
var delMsgIDList [][2]interface{}
|
||||
minSeq, err := deleteMongoMsg(operationID, groupID, oldestList, &delMsgIDList)
|
||||
var delStruct delMsgRecursionStruct
|
||||
minSeq, err := deleteMongoMsg(operationID, groupID, oldestList, &delStruct)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, "deleteMongoMsg failed")
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if minSeq == 0 {
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDList:", delMsgIDList, "minSeq", minSeq)
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDList:", delStruct, "minSeq", minSeq)
|
||||
for _, userID := range userIDList {
|
||||
userMinSeq, err := db.DB.GetGroupUserMinSeq(groupID, userID)
|
||||
if err != nil && err != goRedis.Nil {
|
||||
@ -45,26 +46,23 @@ func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) erro
|
||||
}
|
||||
|
||||
func DeleteMongoMsgAndResetRedisSeq(operationID, userID string) error {
|
||||
var delMsgIDList [][2]interface{}
|
||||
minSeq, err := deleteMongoMsg(operationID, userID, oldestList, &delMsgIDList)
|
||||
var delStruct delMsgRecursionStruct
|
||||
minSeq, err := deleteMongoMsg(operationID, userID, oldestList, &delStruct)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if minSeq == 0 {
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDMap: ", delMsgIDList, "minSeq", minSeq)
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDMap: ", delStruct, "minSeq", minSeq)
|
||||
err = db.DB.SetUserMinSeq(userID, minSeq)
|
||||
return err
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func delMongoMsgs(operationID string, delMsgIDList *[][2]interface{}) error {
|
||||
if len(*delMsgIDList) > 0 {
|
||||
var IDList []string
|
||||
for _, v := range *delMsgIDList {
|
||||
IDList = append(IDList, v[0].(string))
|
||||
}
|
||||
err := db.DB.DelMongoMsgs(IDList)
|
||||
// del list
|
||||
func delMongoMsgsPhysical(uidList []string) error {
|
||||
if len(uidList) > 0 {
|
||||
err := db.DB.DelMongoMsgs(uidList)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "DelMongoMsgs failed")
|
||||
}
|
||||
@ -72,75 +70,106 @@ func delMongoMsgs(operationID string, delMsgIDList *[][2]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type delMsgRecursionStruct struct {
|
||||
minSeq uint32
|
||||
delUidList []string
|
||||
}
|
||||
|
||||
func (d *delMsgRecursionStruct) getSetMinSeq() uint32 {
|
||||
return d.minSeq
|
||||
}
|
||||
|
||||
// index 0....19(del) 20...69
|
||||
// seq 70
|
||||
// set minSeq 21
|
||||
// recursion
|
||||
func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[][2]interface{}) (uint32, error) {
|
||||
// 从最旧的列表开始找
|
||||
func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMsgRecursionStruct) (uint32, error) {
|
||||
// find from oldest list
|
||||
msgs, err := db.DB.GetUserMsgListByIndex(ID, index)
|
||||
if err != nil || msgs.UID == "" {
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
||||
if err == db.ErrMsgListNotExist {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "ID:", ID, "index:", index, err.Error())
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
||||
}
|
||||
}
|
||||
return getDelMaxSeqByIDList(*delMsgIDList), delMongoMsgs(operationID, delMsgIDList)
|
||||
// 获取报错,或者获取不到了,物理删除并且返回seq
|
||||
err = delMongoMsgsPhysical(delStruct.delUidList)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return delStruct.getSetMinSeq(), nil
|
||||
}
|
||||
log.NewDebug(operationID, "ID:", ID, "index:", index, "uid:", msgs.UID, "len:", len(msgs.Msg))
|
||||
if len(msgs.Msg) > db.GetSingleGocMsgNum() {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "msgs too large", len(msgs.Msg), msgs.UID)
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "get msgs: ", msgs.UID)
|
||||
for i, msg := range msgs.Msg {
|
||||
// 找到列表中不需要删除的消息了
|
||||
if utils.GetCurrentTimestampByMill() < msg.SendTime+int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000 {
|
||||
if err := delMongoMsgs(operationID, delMsgIDList); err != nil {
|
||||
// 找到列表中不需要删除的消息了, 表示为递归到最后一个块
|
||||
if utils.GetCurrentTimestampByMill() < msg.SendTime+(int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000) {
|
||||
log.NewDebug(operationID, ID, "find uid", msgs.UID)
|
||||
// 删除块失败 递归结束 返回0
|
||||
if err := delMongoMsgsPhysical(delStruct.delUidList); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
minSeq := getDelMaxSeqByIDList(*delMsgIDList)
|
||||
// unMarshall失败 块删除成功 设置为最小seq
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
if err = proto.Unmarshal(msg.Msg, msgPb); err != nil {
|
||||
return delStruct.getSetMinSeq(), utils.Wrap(err, "")
|
||||
}
|
||||
// 如果不是块中第一个,就把前面比他早插入的全部设置空 seq字段除外。
|
||||
if i > 0 {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
err = db.DB.ReplaceMsgToBlankByIndex(msgs.UID, i-1)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), ID, index)
|
||||
} else {
|
||||
err = db.DB.ReplaceMsgToBlankByIndex(msgs.UID, i-1)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), msgs.UID, i)
|
||||
return minSeq, nil
|
||||
}
|
||||
minSeq = msgPb.Seq
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), msgs.UID, i)
|
||||
return delStruct.getSetMinSeq(), utils.Wrap(err, "")
|
||||
}
|
||||
}
|
||||
return minSeq, nil
|
||||
// 递归结束
|
||||
return msgPb.Seq, nil
|
||||
}
|
||||
}
|
||||
if len(msgs.Msg) > 0 {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, msgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||
return 0, utils.Wrap(err, "proto.Unmarshal failed")
|
||||
}
|
||||
*delMsgIDList = append(*delMsgIDList, [2]interface{}{msgs.UID, msgPb.Seq})
|
||||
}
|
||||
// 没有找到 代表需要全部删除掉 继续递归查找下一个比较旧的列表
|
||||
seq, err := deleteMongoMsg(operationID, utils.GetSelfFuncName(), index+1, delMsgIDList)
|
||||
// 该列表中消息全部为老消息并且列表满了, 加入删除列表继续递归
|
||||
lastMsgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, lastMsgPb)
|
||||
if err != nil {
|
||||
return 0, utils.Wrap(err, "deleteMongoMsg failed")
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||
return 0, utils.Wrap(err, "proto.Unmarshal failed")
|
||||
}
|
||||
delStruct.minSeq = lastMsgPb.Seq
|
||||
if msgListIsFull(msgs) {
|
||||
delStruct.delUidList = append(delStruct.delUidList, msgs.UID)
|
||||
}
|
||||
log.NewDebug(operationID, ID, "continue", delStruct)
|
||||
// 继续递归 index+1
|
||||
seq, err := deleteMongoMsg(operationID, ID, index+1, delStruct)
|
||||
if err != nil {
|
||||
return seq, utils.Wrap(err, "deleteMongoMsg failed")
|
||||
}
|
||||
return seq, nil
|
||||
}
|
||||
|
||||
func getDelMaxSeqByIDList(delMsgIDList [][2]interface{}) uint32 {
|
||||
if len(delMsgIDList) == 0 {
|
||||
return 0
|
||||
func msgListIsFull(chat *db.UserChat) bool {
|
||||
index, _ := strconv.Atoi(strings.Split(chat.UID, ":")[1])
|
||||
if index == 0 {
|
||||
if len(chat.Msg) >= 4999 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return delMsgIDList[len(delMsgIDList)-1][1].(uint32)
|
||||
if len(chat.Msg) >= 5000 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
||||
var maxSeq uint64
|
||||
var seqRedis uint64
|
||||
var err error
|
||||
if diffusionType == constant.WriteDiffusion {
|
||||
maxSeq, err = db.DB.GetUserMaxSeq(ID)
|
||||
seqRedis, err = db.DB.GetUserMaxSeq(ID)
|
||||
} else {
|
||||
maxSeq, err = db.DB.GetGroupMaxSeq(ID)
|
||||
seqRedis, err = db.DB.GetGroupMaxSeq(ID)
|
||||
}
|
||||
if err != nil {
|
||||
if err == goRedis.Nil {
|
||||
@ -152,13 +181,20 @@ func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "GetNewestMsg failed")
|
||||
}
|
||||
if msg == nil {
|
||||
return nil
|
||||
}
|
||||
var seqMongo uint32
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if math.Abs(float64(msgPb.Seq-uint32(maxSeq))) > 10 {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), maxSeq, msgPb.Seq, "redis maxSeq is different with msg.Seq")
|
||||
seqMongo = msgPb.Seq
|
||||
if math.Abs(float64(seqMongo-uint32(seqRedis))) > 10 {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), seqMongo, seqRedis, "redis maxSeq is different with msg.Seq > 10", ID, diffusionType)
|
||||
} else {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), diffusionType, ID, "seq and msg OK", seqMongo, seqRedis)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
34
internal/cron_task/clear_msg_test.go
Normal file
34
internal/cron_task/clear_msg_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package cronTask
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
|
||||
operationID := getCronTaskOperationID()
|
||||
testUserIDList := []string{"test_del_id1", "test_del_id2", "test_del_id3", "test_del_id4", "test_del_id5"}
|
||||
for _, userID := range testUserIDList {
|
||||
operationID = userID + "-" + operationID
|
||||
if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil {
|
||||
t.Error("checkMaxSeqWithMongo failed", userID)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
t.Error("checkMaxSeqWithMongo failed", userID)
|
||||
}
|
||||
}
|
||||
|
||||
testWorkingGroupIDList := []string{"test_del_id1", "test_del_id2", "test_del_id3", "test_del_id4", "test_del_id5"}
|
||||
for _, groupID := range testWorkingGroupIDList {
|
||||
operationID = groupID + "-" + operationID
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "groupID:", groupID, "userIDList:", testUserIDList)
|
||||
if err := ResetUserGroupMinSeq(operationID, groupID, testUserIDList); err != nil {
|
||||
t.Error("checkMaxSeqWithMongo failed", groupID)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
||||
t.Error("checkMaxSeqWithMongo failed", groupID)
|
||||
}
|
||||
}
|
||||
}
|
@ -16,29 +16,33 @@ const cronTaskOperationID = "cronTaskOperationID-"
|
||||
|
||||
func StartCronTask() {
|
||||
log.NewPrivateLog("cron")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task", "cron config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
c := cron.New()
|
||||
fmt.Println("config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
fmt.Println("cron config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, func() {
|
||||
// user msg clear
|
||||
operationID := getCronTaskOperationID()
|
||||
log.NewInfo(operationID, "====================== start del cron task ======================")
|
||||
userIDList, err := im_mysql_model.SelectAllUserID()
|
||||
if err == nil {
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "userIDList: ", userIDList)
|
||||
userIDList = []string{"4158779020"}
|
||||
for _, userID := range userIDList {
|
||||
if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
|
||||
}
|
||||
//if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
// log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
|
||||
//}
|
||||
}
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
|
||||
return
|
||||
// working group msg clear
|
||||
workingGroupIDList, err := im_mysql_model.GetGroupIDListByGroupType(constant.WorkingGroup)
|
||||
if err == nil {
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "workingGroupIDList: ", workingGroupIDList)
|
||||
for _, groupID := range workingGroupIDList {
|
||||
userIDList, err = rocksCache.GetGroupMemberIDListFromCache(groupID)
|
||||
if err != nil {
|
||||
@ -49,26 +53,25 @@ func StartCronTask() {
|
||||
if err := ResetUserGroupMinSeq(operationID, groupID, userIDList); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userIDList)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
|
||||
}
|
||||
//if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
||||
// log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
|
||||
//}
|
||||
}
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(operationID, "====================== start del cron finished ======================")
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("start cron failed", err.Error())
|
||||
fmt.Println("start cron failed", err.Error(), config.Config.Mongo.ChatRecordsClearTime)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c.Start()
|
||||
fmt.Println("start cron task success")
|
||||
for {
|
||||
time.Sleep(time.Second)
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
push "Open_IM/pkg/proto/push"
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
@ -58,7 +59,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
promePkg.PromeInc(promePkg.PullMsgBySeqListTotalCounter)
|
||||
case constant.WsLogoutMsg:
|
||||
log.NewInfo(m.OperationID, "conn.Close()", m.SendID, m.MsgIncr, m.ReqIdentifier)
|
||||
// conn.Close()
|
||||
ws.userLogoutReq(conn, &m)
|
||||
default:
|
||||
log.Error(m.OperationID, "ReqIdentifier failed ", m.SendID, m.MsgIncr, m.ReqIdentifier)
|
||||
}
|
||||
@ -157,7 +158,6 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
ws.pullMsgBySeqListResp(conn, m, nReply)
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullMessageBySeqListResp) {
|
||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
|
||||
c, _ := proto.Marshal(pb)
|
||||
@ -173,7 +173,40 @@ func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullM
|
||||
len(mReply.Data))
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
func (ws *WServer) userLogoutReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to userLogoutReq start", m.SendID, m.ReqIdentifier, m.MsgIncr, string(m.Data))
|
||||
rpcReq := push.DelUserPushTokenReq{}
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName, m.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(rpcReq.OperationID, errMsg)
|
||||
ws.userLogoutResp(conn, m)
|
||||
return
|
||||
}
|
||||
msgClient := push.NewPushMsgServiceClient(grpcConn)
|
||||
reply, err := msgClient.DelUserPushToken(context.Background(), &rpcReq)
|
||||
if err != nil {
|
||||
log.NewError(rpcReq.OperationID, "DelUserPushToken err", err.Error())
|
||||
|
||||
ws.userLogoutResp(conn, m)
|
||||
} else {
|
||||
log.NewInfo(rpcReq.OperationID, "rpc call success to DelUserPushToken", reply.String())
|
||||
ws.userLogoutResp(conn, m)
|
||||
}
|
||||
ws.userLogoutResp(conn, m)
|
||||
|
||||
}
|
||||
func (ws *WServer) userLogoutResp(conn *UserConn, m *Req) {
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
MsgIncr: m.MsgIncr,
|
||||
OperationID: m.OperationID,
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
_ = conn.Close()
|
||||
}
|
||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
sendMsgAllCountLock.Lock()
|
||||
sendMsgAllCount++
|
||||
@ -233,6 +266,7 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
||||
Data: b,
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
|
||||
}
|
||||
|
||||
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
type UserConn struct {
|
||||
*websocket.Conn
|
||||
w *sync.Mutex
|
||||
platformID int32
|
||||
PushedMaxSeq uint32
|
||||
}
|
||||
type WServer struct {
|
||||
@ -74,7 +75,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Error(operationID, "upgrade http conn err", err.Error(), query)
|
||||
return
|
||||
} else {
|
||||
newConn := &UserConn{conn, new(sync.Mutex), 0}
|
||||
newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0}
|
||||
userCount++
|
||||
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], operationID)
|
||||
go ws.readMsg(newConn)
|
||||
|
@ -3,6 +3,7 @@ package logic
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -91,3 +91,15 @@ func (r *RPCServer) PushMsg(_ context.Context, pbData *pbPush.PushMsgReq) (*pbPu
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RPCServer) DelUserPushToken(c context.Context, req *pbPush.DelUserPushTokenReq) (*pbPush.DelUserPushTokenResp, error) {
|
||||
var resp pbPush.DelUserPushTokenResp
|
||||
err := db.DB.DelFcmToken(req.UserID, int(req.PlatformID))
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "SetFcmToken failed " + err.Error()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
@ -28,8 +28,13 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||
var user db.User
|
||||
utils.CopyStructFields(&user, req.UserInfo)
|
||||
if req.UserInfo.Birth != 0 {
|
||||
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||
if req.UserInfo.BirthStr != "" {
|
||||
time, err := utils.TimeStringToTime(req.UserInfo.BirthStr)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "TimeStringToTime failed ", err.Error(), req.UserInfo.BirthStr)
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: "TimeStringToTime failed:" + err.Error()}}, nil
|
||||
}
|
||||
user.Birth = time
|
||||
}
|
||||
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
||||
err := imdb.UserRegister(user)
|
||||
|
@ -61,9 +61,9 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
|
||||
msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, failedSeqList, in.OperationID)
|
||||
if err1 != nil {
|
||||
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
||||
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err.Error())
|
||||
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error())
|
||||
resp.ErrCode = 201
|
||||
resp.ErrMsg = err.Error()
|
||||
resp.ErrMsg = err1.Error()
|
||||
return resp, nil
|
||||
} else {
|
||||
promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList))
|
||||
@ -88,9 +88,9 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
|
||||
msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, in.OperationID)
|
||||
if err1 != nil {
|
||||
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
||||
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err.Error())
|
||||
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error())
|
||||
resp.ErrCode = 201
|
||||
resp.ErrMsg = err.Error()
|
||||
resp.ErrMsg = err1.Error()
|
||||
return resp, nil
|
||||
} else {
|
||||
promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList))
|
||||
|
@ -125,7 +125,6 @@ func syncPeerUserConversation(conversation *pbConversation.Conversation, operati
|
||||
|
||||
func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetUserInfo args ", req.String())
|
||||
|
||||
var userInfoList []*sdkws.UserInfo
|
||||
if len(req.UserIDList) > 0 {
|
||||
for _, userID := range req.UserIDList {
|
||||
@ -136,7 +135,7 @@ func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq
|
||||
continue
|
||||
}
|
||||
utils.CopyStructFields(&userInfo, user)
|
||||
userInfo.Birth = uint32(user.Birth.Unix())
|
||||
userInfo.BirthStr = utils.TimeToString(user.Birth)
|
||||
userInfoList = append(userInfoList, &userInfo)
|
||||
}
|
||||
} else {
|
||||
@ -411,8 +410,14 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
||||
}
|
||||
var user db.User
|
||||
utils.CopyStructFields(&user, req.UserInfo)
|
||||
if req.UserInfo.Birth != 0 {
|
||||
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||
|
||||
if req.UserInfo.BirthStr != "" {
|
||||
time, err := utils.TimeStringToTime(req.UserInfo.BirthStr)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "TimeStringToTime failed ", err.Error(), req.UserInfo.BirthStr)
|
||||
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: "TimeStringToTime failed:" + err.Error()}}, nil
|
||||
}
|
||||
user.Birth = time
|
||||
}
|
||||
|
||||
err := imdb.UpdateUserInfo(user)
|
||||
@ -600,7 +605,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
||||
var user sdkws.UserInfo
|
||||
utils.CopyStructFields(&user, userDB)
|
||||
user.CreateTime = uint32(userDB.CreateTime.Unix())
|
||||
user.Birth = uint32(userDB.Birth.Unix())
|
||||
user.BirthStr = utils.TimeToString(userDB.Birth)
|
||||
resp.UserList = append(resp.UserList, &pbUser.CmsUser{User: &user})
|
||||
}
|
||||
|
||||
@ -628,7 +633,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
||||
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.AddUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||
err := imdb.AddUser(req.UserInfo.UserID, req.UserInfo.PhoneNumber, req.UserInfo.Nickname, req.UserInfo.Email, req.UserInfo.Gender, req.UserInfo.FaceURL, req.UserInfo.Birth)
|
||||
err := imdb.AddUser(req.UserInfo.UserID, req.UserInfo.PhoneNumber, req.UserInfo.Nickname, req.UserInfo.Email, req.UserInfo.Gender, req.UserInfo.FaceURL, req.UserInfo.BirthStr)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error(), req.String())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
|
@ -17,6 +17,7 @@ type ApiUserInfo struct {
|
||||
CreateTime int64 `json:"createTime"`
|
||||
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
|
||||
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
||||
BirthStr string `json:"birthStr" binding:"omitempty"`
|
||||
}
|
||||
|
||||
//type Conversation struct {
|
||||
|
@ -410,15 +410,19 @@ func (d *DataBases) GetSendMsgStatus(operationID string) (int, error) {
|
||||
return status, err
|
||||
}
|
||||
|
||||
func (d *DataBases) SetFcmToken(account string, platformid int, fcmToken string, expireTime int64) (err error) {
|
||||
key := FcmToken + account + ":" + strconv.Itoa(platformid)
|
||||
func (d *DataBases) SetFcmToken(account string, platformID int, fcmToken string, expireTime int64) (err error) {
|
||||
key := FcmToken + account + ":" + strconv.Itoa(platformID)
|
||||
return d.RDB.Set(context.Background(), key, fcmToken, time.Duration(expireTime)*time.Second).Err()
|
||||
}
|
||||
|
||||
func (d *DataBases) GetFcmToken(account string, platformid int) (string, error) {
|
||||
key := FcmToken + account + ":" + strconv.Itoa(platformid)
|
||||
func (d *DataBases) GetFcmToken(account string, platformID int) (string, error) {
|
||||
key := FcmToken + account + ":" + strconv.Itoa(platformID)
|
||||
return d.RDB.Get(context.Background(), key).Result()
|
||||
}
|
||||
func (d *DataBases) DelFcmToken(account string, platformID int) error {
|
||||
key := FcmToken + account + ":" + strconv.Itoa(platformID)
|
||||
return d.RDB.Del(context.Background(), key).Err()
|
||||
}
|
||||
func (d *DataBases) IncrUserBadgeUnreadCountSum(uid string) (int, error) {
|
||||
key := userBadgeUnreadCountSum + uid
|
||||
seq, err := d.RDB.Incr(context.Background(), key).Result()
|
||||
|
@ -125,23 +125,6 @@ func init() {
|
||||
fmt.Println("createMongoIndex success")
|
||||
DB.mongoClient = mongoClient
|
||||
|
||||
// redis pool init
|
||||
//DB.redisPool = &redis.Pool{
|
||||
// MaxIdle: config.Config.Redis.DBMaxIdle,
|
||||
// MaxActive: config.Config.Redis.DBMaxActive,
|
||||
// IdleTimeout: time.Duration(config.Config.Redis.DBIdleTimeout) * time.Second,
|
||||
// Dial: func() (redis.Conn, error) {
|
||||
// return redis.Dial(
|
||||
// "tcp",
|
||||
// config.Config.Redis.DBAddress,
|
||||
// redis.DialReadTimeout(time.Duration(1000)*time.Millisecond),
|
||||
// redis.DialWriteTimeout(time.Duration(1000)*time.Millisecond),
|
||||
// redis.DialConnectTimeout(time.Duration(1000)*time.Millisecond),
|
||||
// redis.DialDatabase(0),
|
||||
// redis.DialPassword(config.Config.Redis.DBPassWord),
|
||||
// )
|
||||
// },
|
||||
//}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if config.Config.Redis.EnableCluster {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/gogo/protobuf/sortkeys"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"math/rand"
|
||||
@ -55,6 +56,8 @@ type GroupMember_x struct {
|
||||
UIDList []string
|
||||
}
|
||||
|
||||
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
|
||||
|
||||
func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
||||
return 1, nil
|
||||
//var i, NB uint32
|
||||
@ -265,18 +268,19 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er
|
||||
regex := fmt.Sprintf("^%s", ID)
|
||||
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
||||
var msgs []UserChat
|
||||
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = cursor.Decode(&msgs)
|
||||
//primitive.Regex{Pattern: regex}
|
||||
cursor, err := c.Find(ctx, bson.M{"uid": primitive.Regex{Pattern: regex}}, findOpts)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
err = cursor.All(context.Background(), &msgs)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, fmt.Sprintf("cursor is %s", cursor.Current.String()))
|
||||
}
|
||||
if len(msgs) > 0 {
|
||||
return &msgs[0], err
|
||||
return &msgs[0], nil
|
||||
} else {
|
||||
return nil, errors.New("get msg list failed")
|
||||
return nil, ErrMsgListNotExist
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,11 +301,20 @@ func (d *DataBases) ReplaceMsgToBlankByIndex(suffixID string, index int) error {
|
||||
}
|
||||
for i, msg := range userChat.Msg {
|
||||
if i <= index {
|
||||
msg.Msg = nil
|
||||
msgPb := &open_im_sdk.MsgData{}
|
||||
if err = proto.Unmarshal(msg.Msg, msgPb); err != nil {
|
||||
continue
|
||||
}
|
||||
newMsgPb := &open_im_sdk.MsgData{Seq: msgPb.Seq}
|
||||
bytes, err := proto.Marshal(newMsgPb)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
msg.Msg = bytes
|
||||
msg.SendTime = 0
|
||||
}
|
||||
}
|
||||
_, err = c.UpdateOne(ctx, bson.M{"uid": suffixID}, userChat)
|
||||
_, err = c.UpdateOne(ctx, bson.M{"uid": suffixID}, bson.M{"$set": bson.M{"msg": userChat.Msg}})
|
||||
return err
|
||||
}
|
||||
|
||||
@ -315,17 +328,17 @@ func (d *DataBases) GetNewestMsg(ID string) (msg *MsgInfo, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = cursor.Decode(&userChats)
|
||||
err = cursor.All(ctx, &userChats)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
if len(userChats) > 0 {
|
||||
if len(userChats[0].Msg) > 0 {
|
||||
return &userChats[0].Msg[len(userChats[0].Msg)], nil
|
||||
return &userChats[0].Msg[len(userChats[0].Msg)-1], nil
|
||||
}
|
||||
return nil, errors.New("len(userChats[0].Msg) < 0")
|
||||
}
|
||||
return nil, errors.New("len(userChats) < 0")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -116,10 +115,10 @@ func GetUsers(showNumber, pageNumber int32) ([]db.User, error) {
|
||||
return users, err
|
||||
}
|
||||
|
||||
func AddUser(userID string, phoneNumber string, name string, email string, gender int32, faceURL string, birth uint32) error {
|
||||
_birth, _err := time.ParseInLocation("2006-01-02", strconv.Itoa(int(birth)), time.Local)
|
||||
if _err != nil {
|
||||
_birth = time.Now()
|
||||
func AddUser(userID string, phoneNumber string, name string, email string, gender int32, faceURL string, birth string) error {
|
||||
_birth, err := utils.TimeStringToTime(birth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user := db.User{
|
||||
UserID: userID,
|
||||
|
@ -39,35 +39,3 @@ func (f *fileHook) Fire(entry *logrus.Entry) error {
|
||||
entry.Data["FilePath"] = s
|
||||
return nil
|
||||
}
|
||||
|
||||
//func findCaller(skip int) string {
|
||||
// file := ""
|
||||
// line := 0
|
||||
// for i := 0; i < 10; i++ {
|
||||
// file, line = getCaller(skip + i)
|
||||
// if !strings.HasPrefix(file, "log") {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// return fmt.Sprintf("%s:%d", file, line)
|
||||
//}
|
||||
//
|
||||
//func getCaller(skip int) (string, int) {
|
||||
// _, file, line, ok := runtime.Caller(skip)
|
||||
//
|
||||
// if !ok {
|
||||
// return "", 0
|
||||
// }
|
||||
// fmt.Println("skip:", skip, "file:", file, "line", line)
|
||||
// n := 0
|
||||
// for i := len(file) - 1; i > 0; i-- {
|
||||
// if file[i] == '/' {
|
||||
// n++
|
||||
// if n >= 2 {
|
||||
// file = file[i+1:]
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return file, line
|
||||
//}
|
||||
|
12
pkg/common/token_verify/jwt_token_test.go
Normal file
12
pkg/common/token_verify/jwt_token_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
package token_verify
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_ParseToken(t *testing.T) {
|
||||
token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiJvcGVuSU1BZG1pbiIsIlBsYXRmb3JtIjoiQVBhZCIsImV4cCI6MTY3NDYxNTA2MSwibmJmIjoxNjY2ODM4NzYxLCJpYXQiOjE2NjY4MzkwNjF9.l8RiIu6pR4ItwDOpNIDYA9LBzIcpk8r8n6NRtXjqOp8"
|
||||
_, err := GetClaimFromToken(token)
|
||||
assert.Nil(t, err)
|
||||
}
|
@ -146,14 +146,15 @@ func GroupRequestDBCopyOpenIM(dst *open_im_sdk.GroupRequest, src *db.GroupReques
|
||||
|
||||
func UserOpenIMCopyDB(dst *db.User, src *open_im_sdk.UserInfo) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.Birth = utils.UnixSecondToTime(int64(src.Birth))
|
||||
dst.Birth, _ = utils.TimeStringToTime(src.BirthStr)
|
||||
dst.CreateTime = utils.UnixSecondToTime(int64(src.CreateTime))
|
||||
}
|
||||
|
||||
func UserDBCopyOpenIM(dst *open_im_sdk.UserInfo, src *db.User) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.CreateTime = uint32(src.CreateTime.Unix())
|
||||
dst.Birth = uint32(src.Birth.Unix())
|
||||
//dst.Birth = uint32(src.Birth.Unix())
|
||||
dst.BirthStr = utils.TimeToString(src.Birth)
|
||||
}
|
||||
|
||||
func UserDBCopyOpenIMPublicUser(dst *open_im_sdk.PublicUserInfo, src *db.User) {
|
||||
|
@ -1,291 +1,274 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.15.5
|
||||
// source: push/push.proto
|
||||
|
||||
package pbPush
|
||||
package pbPush // import "Open_IM/pkg/proto/push"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
|
||||
import (
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
context "context"
|
||||
context "golang.org/x/net/context"
|
||||
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 (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type PushMsgReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OperationID string `protobuf:"bytes,1,opt,name=operationID,proto3" json:"operationID,omitempty"`
|
||||
MsgData *sdk_ws.MsgData `protobuf:"bytes,2,opt,name=msgData,proto3" json:"msgData,omitempty"`
|
||||
PushToUserID string `protobuf:"bytes,3,opt,name=pushToUserID,proto3" json:"pushToUserID,omitempty"`
|
||||
OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"`
|
||||
MsgData *sdk_ws.MsgData `protobuf:"bytes,2,opt,name=msgData" json:"msgData,omitempty"`
|
||||
PushToUserID string `protobuf:"bytes,3,opt,name=pushToUserID" json:"pushToUserID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (x *PushMsgReq) Reset() {
|
||||
*x = PushMsgReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_push_push_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PushMsgReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PushMsgReq) ProtoMessage() {}
|
||||
|
||||
func (x *PushMsgReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_push_push_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)
|
||||
}
|
||||
|
||||
// Deprecated: Use PushMsgReq.ProtoReflect.Descriptor instead.
|
||||
func (m *PushMsgReq) Reset() { *m = PushMsgReq{} }
|
||||
func (m *PushMsgReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*PushMsgReq) ProtoMessage() {}
|
||||
func (*PushMsgReq) Descriptor() ([]byte, []int) {
|
||||
return file_push_push_proto_rawDescGZIP(), []int{0}
|
||||
return fileDescriptor_push_17f752d1b1c8edd5, []int{0}
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PushMsgReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PushMsgReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PushMsgReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PushMsgReq.Merge(dst, src)
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Size() int {
|
||||
return xxx_messageInfo_PushMsgReq.Size(m)
|
||||
}
|
||||
func (m *PushMsgReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PushMsgReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
func (x *PushMsgReq) GetOperationID() string {
|
||||
if x != nil {
|
||||
return x.OperationID
|
||||
var xxx_messageInfo_PushMsgReq proto.InternalMessageInfo
|
||||
|
||||
func (m *PushMsgReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PushMsgReq) GetMsgData() *sdk_ws.MsgData {
|
||||
if x != nil {
|
||||
return x.MsgData
|
||||
func (m *PushMsgReq) GetMsgData() *sdk_ws.MsgData {
|
||||
if m != nil {
|
||||
return m.MsgData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PushMsgReq) GetPushToUserID() string {
|
||||
if x != nil {
|
||||
return x.PushToUserID
|
||||
func (m *PushMsgReq) GetPushToUserID() string {
|
||||
if m != nil {
|
||||
return m.PushToUserID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PushMsgResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ResultCode int32 `protobuf:"varint,1,opt,name=ResultCode,proto3" json:"ResultCode,omitempty"`
|
||||
ResultCode int32 `protobuf:"varint,1,opt,name=ResultCode" json:"ResultCode,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (x *PushMsgResp) Reset() {
|
||||
*x = PushMsgResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_push_push_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PushMsgResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PushMsgResp) ProtoMessage() {}
|
||||
|
||||
func (x *PushMsgResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_push_push_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)
|
||||
}
|
||||
|
||||
// Deprecated: Use PushMsgResp.ProtoReflect.Descriptor instead.
|
||||
func (m *PushMsgResp) Reset() { *m = PushMsgResp{} }
|
||||
func (m *PushMsgResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*PushMsgResp) ProtoMessage() {}
|
||||
func (*PushMsgResp) Descriptor() ([]byte, []int) {
|
||||
return file_push_push_proto_rawDescGZIP(), []int{1}
|
||||
return fileDescriptor_push_17f752d1b1c8edd5, []int{1}
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PushMsgResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PushMsgResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PushMsgResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PushMsgResp.Merge(dst, src)
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Size() int {
|
||||
return xxx_messageInfo_PushMsgResp.Size(m)
|
||||
}
|
||||
func (m *PushMsgResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PushMsgResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
func (x *PushMsgResp) GetResultCode() int32 {
|
||||
if x != nil {
|
||||
return x.ResultCode
|
||||
var xxx_messageInfo_PushMsgResp proto.InternalMessageInfo
|
||||
|
||||
func (m *PushMsgResp) GetResultCode() int32 {
|
||||
if m != nil {
|
||||
return m.ResultCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_push_push_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_push_push_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x70, 0x75, 0x73, 0x68, 0x2f, 0x70, 0x75, 0x73, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x04, 0x70, 0x75, 0x73, 0x68, 0x1a, 0x28, 0x4f, 0x70, 0x65, 0x6e, 0x2d, 0x49, 0x4d,
|
||||
0x2d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2f, 0x73, 0x64, 0x6b, 0x5f, 0x77, 0x73, 0x2f, 0x77, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0x88, 0x01, 0x0a, 0x0a, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71,
|
||||
0x12, 0x20, 0x0a, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x49, 0x44, 0x12, 0x34, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69,
|
||||
0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52,
|
||||
0x07, 0x6d, 0x73, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x75, 0x73, 0x68,
|
||||
0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
|
||||
0x70, 0x75, 0x73, 0x68, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x2d, 0x0a, 0x0b,
|
||||
0x50, 0x75, 0x73, 0x68, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x52,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0a, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x32, 0x40, 0x0a, 0x0e, 0x50,
|
||||
0x75, 0x73, 0x68, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2e, 0x0a,
|
||||
0x07, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x73, 0x67, 0x12, 0x10, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x2e,
|
||||
0x50, 0x75, 0x73, 0x68, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x70, 0x75, 0x73,
|
||||
0x68, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x73, 0x70, 0x42, 0x1f, 0x5a,
|
||||
0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x5f, 0x49, 0x4d, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x2f, 0x70, 0x75, 0x73, 0x68, 0x3b, 0x70, 0x62, 0x50, 0x75, 0x73, 0x68, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
type DelUserPushTokenReq struct {
|
||||
OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"`
|
||||
UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"`
|
||||
PlatformID int32 `protobuf:"varint,3,opt,name=platformID" json:"platformID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
var (
|
||||
file_push_push_proto_rawDescOnce sync.Once
|
||||
file_push_push_proto_rawDescData = file_push_push_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_push_push_proto_rawDescGZIP() []byte {
|
||||
file_push_push_proto_rawDescOnce.Do(func() {
|
||||
file_push_push_proto_rawDescData = protoimpl.X.CompressGZIP(file_push_push_proto_rawDescData)
|
||||
})
|
||||
return file_push_push_proto_rawDescData
|
||||
func (m *DelUserPushTokenReq) Reset() { *m = DelUserPushTokenReq{} }
|
||||
func (m *DelUserPushTokenReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*DelUserPushTokenReq) ProtoMessage() {}
|
||||
func (*DelUserPushTokenReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_push_17f752d1b1c8edd5, []int{2}
|
||||
}
|
||||
func (m *DelUserPushTokenReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DelUserPushTokenReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DelUserPushTokenReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DelUserPushTokenReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *DelUserPushTokenReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DelUserPushTokenReq.Merge(dst, src)
|
||||
}
|
||||
func (m *DelUserPushTokenReq) XXX_Size() int {
|
||||
return xxx_messageInfo_DelUserPushTokenReq.Size(m)
|
||||
}
|
||||
func (m *DelUserPushTokenReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DelUserPushTokenReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var file_push_push_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_push_push_proto_goTypes = []interface{}{
|
||||
(*PushMsgReq)(nil), // 0: push.PushMsgReq
|
||||
(*PushMsgResp)(nil), // 1: push.PushMsgResp
|
||||
(*sdk_ws.MsgData)(nil), // 2: server_api_params.MsgData
|
||||
}
|
||||
var file_push_push_proto_depIdxs = []int32{
|
||||
2, // 0: push.PushMsgReq.msgData:type_name -> server_api_params.MsgData
|
||||
0, // 1: push.PushMsgService.PushMsg:input_type -> push.PushMsgReq
|
||||
1, // 2: push.PushMsgService.PushMsg:output_type -> push.PushMsgResp
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
var xxx_messageInfo_DelUserPushTokenReq proto.InternalMessageInfo
|
||||
|
||||
func init() { file_push_push_proto_init() }
|
||||
func file_push_push_proto_init() {
|
||||
if File_push_push_proto != nil {
|
||||
return
|
||||
func (m *DelUserPushTokenReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_push_push_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PushMsgReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_push_push_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PushMsgResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *DelUserPushTokenReq) GetUserID() string {
|
||||
if m != nil {
|
||||
return m.UserID
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_push_push_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_push_push_proto_goTypes,
|
||||
DependencyIndexes: file_push_push_proto_depIdxs,
|
||||
MessageInfos: file_push_push_proto_msgTypes,
|
||||
}.Build()
|
||||
File_push_push_proto = out.File
|
||||
file_push_push_proto_rawDesc = nil
|
||||
file_push_push_proto_goTypes = nil
|
||||
file_push_push_proto_depIdxs = nil
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *DelUserPushTokenReq) GetPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.PlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type DelUserPushTokenResp struct {
|
||||
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 (m *DelUserPushTokenResp) Reset() { *m = DelUserPushTokenResp{} }
|
||||
func (m *DelUserPushTokenResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*DelUserPushTokenResp) ProtoMessage() {}
|
||||
func (*DelUserPushTokenResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_push_17f752d1b1c8edd5, []int{3}
|
||||
}
|
||||
func (m *DelUserPushTokenResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DelUserPushTokenResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DelUserPushTokenResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DelUserPushTokenResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *DelUserPushTokenResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DelUserPushTokenResp.Merge(dst, src)
|
||||
}
|
||||
func (m *DelUserPushTokenResp) XXX_Size() int {
|
||||
return xxx_messageInfo_DelUserPushTokenResp.Size(m)
|
||||
}
|
||||
func (m *DelUserPushTokenResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DelUserPushTokenResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DelUserPushTokenResp proto.InternalMessageInfo
|
||||
|
||||
func (m *DelUserPushTokenResp) GetErrCode() int32 {
|
||||
if m != nil {
|
||||
return m.ErrCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DelUserPushTokenResp) GetErrMsg() string {
|
||||
if m != nil {
|
||||
return m.ErrMsg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PushMsgReq)(nil), "push.PushMsgReq")
|
||||
proto.RegisterType((*PushMsgResp)(nil), "push.PushMsgResp")
|
||||
proto.RegisterType((*DelUserPushTokenReq)(nil), "push.DelUserPushTokenReq")
|
||||
proto.RegisterType((*DelUserPushTokenResp)(nil), "push.DelUserPushTokenResp")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConnInterface
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion6
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for PushMsgService service
|
||||
|
||||
// PushMsgServiceClient is the client API for PushMsgService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type PushMsgServiceClient interface {
|
||||
PushMsg(ctx context.Context, in *PushMsgReq, opts ...grpc.CallOption) (*PushMsgResp, error)
|
||||
DelUserPushToken(ctx context.Context, in *DelUserPushTokenReq, opts ...grpc.CallOption) (*DelUserPushTokenResp, error)
|
||||
}
|
||||
|
||||
type pushMsgServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewPushMsgServiceClient(cc grpc.ClientConnInterface) PushMsgServiceClient {
|
||||
func NewPushMsgServiceClient(cc *grpc.ClientConn) PushMsgServiceClient {
|
||||
return &pushMsgServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *pushMsgServiceClient) PushMsg(ctx context.Context, in *PushMsgReq, opts ...grpc.CallOption) (*PushMsgResp, error) {
|
||||
out := new(PushMsgResp)
|
||||
err := c.cc.Invoke(ctx, "/push.PushMsgService/PushMsg", in, out, opts...)
|
||||
err := grpc.Invoke(ctx, "/push.PushMsgService/PushMsg", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PushMsgServiceServer is the server API for PushMsgService service.
|
||||
func (c *pushMsgServiceClient) DelUserPushToken(ctx context.Context, in *DelUserPushTokenReq, opts ...grpc.CallOption) (*DelUserPushTokenResp, error) {
|
||||
out := new(DelUserPushTokenResp)
|
||||
err := grpc.Invoke(ctx, "/push.PushMsgService/DelUserPushToken", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for PushMsgService service
|
||||
|
||||
type PushMsgServiceServer interface {
|
||||
PushMsg(context.Context, *PushMsgReq) (*PushMsgResp, error)
|
||||
}
|
||||
|
||||
// UnimplementedPushMsgServiceServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPushMsgServiceServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedPushMsgServiceServer) PushMsg(context.Context, *PushMsgReq) (*PushMsgResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PushMsg not implemented")
|
||||
DelUserPushToken(context.Context, *DelUserPushTokenReq) (*DelUserPushTokenResp, error)
|
||||
}
|
||||
|
||||
func RegisterPushMsgServiceServer(s *grpc.Server, srv PushMsgServiceServer) {
|
||||
@ -310,6 +293,24 @@ func _PushMsgService_PushMsg_Handler(srv interface{}, ctx context.Context, dec f
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PushMsgService_DelUserPushToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DelUserPushTokenReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PushMsgServiceServer).DelUserPushToken(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/push.PushMsgService/DelUserPushToken",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PushMsgServiceServer).DelUserPushToken(ctx, req.(*DelUserPushTokenReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _PushMsgService_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "push.PushMsgService",
|
||||
HandlerType: (*PushMsgServiceServer)(nil),
|
||||
@ -318,7 +319,39 @@ var _PushMsgService_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "PushMsg",
|
||||
Handler: _PushMsgService_PushMsg_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DelUserPushToken",
|
||||
Handler: _PushMsgService_DelUserPushToken_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "push/push.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("push/push.proto", fileDescriptor_push_17f752d1b1c8edd5) }
|
||||
|
||||
var fileDescriptor_push_17f752d1b1c8edd5 = []byte{
|
||||
// 342 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4f, 0x4b, 0xfb, 0x40,
|
||||
0x10, 0x25, 0xfd, 0xfd, 0xda, 0xe2, 0x54, 0xb4, 0xae, 0x22, 0x31, 0xa0, 0x96, 0x9c, 0x7a, 0x69,
|
||||
0x02, 0xd5, 0x9b, 0x37, 0xcd, 0xc1, 0x1c, 0x82, 0x25, 0xea, 0xc5, 0x4b, 0xd8, 0xda, 0x35, 0x2d,
|
||||
0xfd, 0xb3, 0xe3, 0x4e, 0x62, 0xbf, 0x82, 0xe0, 0x97, 0x96, 0xdd, 0x24, 0x1a, 0xab, 0x82, 0x97,
|
||||
0x65, 0xe7, 0xcd, 0xdb, 0x79, 0x6f, 0x76, 0x06, 0x76, 0x31, 0xa7, 0xa9, 0xaf, 0x0f, 0x0f, 0x95,
|
||||
0xcc, 0x24, 0xfb, 0xaf, 0xef, 0x4e, 0xff, 0x06, 0xc5, 0x6a, 0x10, 0x46, 0x83, 0x5b, 0xa1, 0x5e,
|
||||
0x84, 0xf2, 0x71, 0x9e, 0xfa, 0x26, 0xef, 0xd3, 0x64, 0x9e, 0xac, 0xc9, 0x5f, 0x53, 0xc1, 0x77,
|
||||
0x5f, 0x2d, 0x80, 0x51, 0x4e, 0xd3, 0x88, 0xd2, 0x58, 0x3c, 0xb3, 0x1e, 0x74, 0x24, 0x0a, 0xc5,
|
||||
0xb3, 0x99, 0x5c, 0x85, 0x81, 0x6d, 0xf5, 0xac, 0xfe, 0x56, 0x5c, 0x87, 0xd8, 0x39, 0xb4, 0x97,
|
||||
0x94, 0x06, 0x3c, 0xe3, 0x76, 0xa3, 0x67, 0xf5, 0x3b, 0x43, 0xc7, 0x23, 0x23, 0x92, 0x70, 0x9c,
|
||||
0x25, 0xc8, 0x15, 0x5f, 0x92, 0x17, 0x15, 0x8c, 0xb8, 0xa2, 0x32, 0x17, 0xb6, 0xb5, 0xb1, 0x3b,
|
||||
0x79, 0x4f, 0x42, 0x85, 0x81, 0xfd, 0xcf, 0x14, 0xfe, 0x82, 0xb9, 0x03, 0xe8, 0x7c, 0x38, 0x21,
|
||||
0x64, 0x27, 0x00, 0xb1, 0xa0, 0x7c, 0x91, 0x5d, 0xc9, 0x89, 0x30, 0x4e, 0x9a, 0x71, 0x0d, 0x71,
|
||||
0x25, 0xec, 0x07, 0x62, 0xa1, 0xdf, 0x8e, 0x4c, 0x95, 0xb9, 0x58, 0xfd, 0xad, 0x83, 0x43, 0x68,
|
||||
0xe5, 0x85, 0x8b, 0x86, 0x49, 0x96, 0x91, 0x16, 0xc4, 0x05, 0xcf, 0x9e, 0xa4, 0x5a, 0x96, 0x0e,
|
||||
0x9b, 0x71, 0x0d, 0x71, 0xaf, 0xe1, 0xe0, 0xbb, 0x20, 0x21, 0xb3, 0xa1, 0x2d, 0x94, 0xaa, 0xb9,
|
||||
0xac, 0x42, 0xad, 0x24, 0x94, 0x8a, 0x28, 0xad, 0x94, 0x8a, 0x68, 0xf8, 0x66, 0xc1, 0x4e, 0xd9,
|
||||
0xaa, 0x1e, 0xd0, 0xec, 0x51, 0x30, 0x0f, 0xda, 0x25, 0xc2, 0xba, 0x9e, 0x99, 0xe7, 0xe7, 0x54,
|
||||
0x9c, 0xbd, 0x0d, 0x84, 0x90, 0x85, 0xd0, 0xdd, 0x34, 0xc3, 0x8e, 0x0a, 0xda, 0x0f, 0xbf, 0xe2,
|
||||
0x38, 0xbf, 0xa5, 0x08, 0x2f, 0x4f, 0x1f, 0x8e, 0xf5, 0xba, 0x24, 0x61, 0x54, 0xdb, 0x13, 0x4d,
|
||||
0xbf, 0xc0, 0xb1, 0x66, 0x8e, 0x5b, 0x06, 0x3a, 0x7b, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x44,
|
||||
0x0e, 0xd2, 0x6d, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
@ -11,6 +11,16 @@ message PushMsgReq {
|
||||
message PushMsgResp{
|
||||
int32 ResultCode = 1;
|
||||
}
|
||||
message DelUserPushTokenReq{
|
||||
string operationID = 1;
|
||||
string userID =2;
|
||||
int32 platformID = 3;
|
||||
}
|
||||
message DelUserPushTokenResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
//message InternalPushMsgReq{
|
||||
// int32 ReqIdentifier = 1;
|
||||
// string Token = 2;
|
||||
@ -33,6 +43,7 @@ message PushMsgResp{
|
||||
|
||||
service PushMsgService {
|
||||
rpc PushMsg(PushMsgReq) returns(PushMsgResp);
|
||||
rpc DelUserPushToken(DelUserPushTokenReq) returns(DelUserPushTokenResp);
|
||||
// rpc InternalPushMsg(InternalPushMsgReq)returns(PushMsgResp);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,7 @@ message UserInfo{
|
||||
uint32 createTime = 9;
|
||||
int32 appMangerLevel = 10;
|
||||
int32 globalRecvMsgOpt = 11;
|
||||
string birthStr = 12;
|
||||
}
|
||||
|
||||
message FriendInfo{
|
||||
@ -157,6 +158,7 @@ message OrganizationUser {
|
||||
string email = 9;
|
||||
uint32 createTime = 10;
|
||||
string ex = 11;
|
||||
string birthStr = 12;
|
||||
}
|
||||
|
||||
message DepartmentMember {
|
||||
|
@ -83,3 +83,7 @@ func TimeStringToTime(timeString string) (time.Time, error) {
|
||||
t, err := time.Parse("2006-01-02", timeString)
|
||||
return t, err
|
||||
}
|
||||
|
||||
func TimeToString(t time.Time) string {
|
||||
return t.Format("2006-01-02")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user