errcode
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/auth"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package clientInit
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/api_struct"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SetClientInitConfig(c *gin.Context) {
|
||||
var req api.SetClientInitConfigReq
|
||||
var resp api.SetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := tokenverify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
if err != nil {
|
||||
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.DiscoverPageURL != nil {
|
||||
m["discover_page_url"] = *req.DiscoverPageURL
|
||||
}
|
||||
if len(m) > 0 {
|
||||
err := imdb.SetClientInitConfig(m)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetClientInitConfig(c *gin.Context) {
|
||||
var req api.GetClientInitConfigReq
|
||||
var resp api.GetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := tokenverify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
if err != nil {
|
||||
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
config, err := imdb.GetClientInitConfig()
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
|
||||
}
|
||||
resp.Data.DiscoverPageURL = config.DiscoverPageURL
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package friend
|
||||
// "Open_IM/pkg/common/tokenverify"
|
||||
// "Open_IM/pkg/getcdv3"
|
||||
// rpc "Open_IM/pkg/proto/friend"
|
||||
// open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
// open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
// "Open_IM/pkg/utils"
|
||||
// "context"
|
||||
// "github.com/gin-gonic/gin"
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/msg"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -32,7 +32,7 @@ func GetSeq(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
pbData := sdkws.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
|
||||
"Open_IM/pkg/getcdv3"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbOffice "Open_IM/pkg/proto/office"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbOffice "Open_IM/pkg/proto/office"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"Open_IM/pkg/getcdv3"
|
||||
cacheRpc "Open_IM/pkg/proto/cache"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
common "Open_IM/pkg/proto/sdk_ws"
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbAdminCms "Open_IM/pkg/proto/admin_cms"
|
||||
common "Open_IM/pkg/proto/sdk_ws"
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
pb "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*server_api_params.FriendInfo, error) {
|
||||
func GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*sdkws.FriendInfo, error) {
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"errors"
|
||||
)
|
||||
|
||||
@@ -12,6 +12,6 @@ func NewGroupChecker() *GroupChecker {
|
||||
return &GroupChecker{}
|
||||
}
|
||||
|
||||
func (g *GroupChecker) GetGroupInfo(groupID string) (*server_api_params.GroupInfo, error) {
|
||||
func (g *GroupChecker) GetGroupInfo(groupID string) (*sdkws.GroupInfo, error) {
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func GetUsersInfo(ctx context.Context, args ...interface{}) ([]*server_api_params.UserInfo, error) {
|
||||
func GetUsersInfo(ctx context.Context, args ...interface{}) ([]*sdkws.UserInfo, error) {
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package convert
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
sdk "Open_IM/pkg/proto/sdkws"
|
||||
utils "github.com/OpenIMSDK/open_utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mongo"
|
||||
"Open_IM/pkg/common/log"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"math"
|
||||
"strconv"
|
||||
@@ -109,7 +109,7 @@ func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMs
|
||||
}
|
||||
if msgs.Msg[len(msgs.Msg)-1].SendTime+(int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000) > utils.GetCurrentTimestampByMill() && msgListIsFull(msgs) {
|
||||
delStruct.delUidList = append(delStruct.delUidList, msgs.UID)
|
||||
lastMsgPb := &server_api_params.MsgData{}
|
||||
lastMsgPb := &sdkws.MsgData{}
|
||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, lastMsgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||
@@ -119,7 +119,7 @@ func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMs
|
||||
} else {
|
||||
var hasMarkDelFlag bool
|
||||
for _, msg := range msgs.Msg {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
msgPb := &sdkws.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||
|
||||
@@ -3,7 +3,7 @@ package cronTask
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
mongo2 "Open_IM/pkg/common/db/mongo"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@@ -25,7 +25,7 @@ var (
|
||||
func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *mongo2.UserChat {
|
||||
chat := &mongo2.UserChat{UID: userID + strconv.Itoa(int(index))}
|
||||
for i := startSeq; i <= stopSeq; i++ {
|
||||
msg := server_api_params.MsgData{
|
||||
msg := sdkws.MsgData{
|
||||
SendID: "sendID1",
|
||||
RecvID: "recvID1",
|
||||
GroupID: "",
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
@@ -34,8 +33,8 @@ func (r *RPCServer) GenPullSeqList(currentSeq uint32, operationID string, userID
|
||||
return seqList, nil
|
||||
}
|
||||
|
||||
func (r *RPCServer) GetSingleUserMsgForPushPlatforms(operationID string, msgData *sdk_ws.MsgData, pushToUserID string, platformIDList []int) map[int]*sdk_ws.MsgDataList {
|
||||
user2PushMsg := make(map[int]*sdk_ws.MsgDataList, 0)
|
||||
func (r *RPCServer) GetSingleUserMsgForPushPlatforms(operationID string, msgData *sdkws.MsgData, pushToUserID string, platformIDList []int) map[int]*sdkws.MsgDataList {
|
||||
user2PushMsg := make(map[int]*sdkws.MsgDataList, 0)
|
||||
for _, v := range platformIDList {
|
||||
user2PushMsg[v] = r.GetSingleUserMsgForPush(operationID, msgData, pushToUserID, v)
|
||||
//log.Info(operationID, "GetSingleUserMsgForPush", msgData.Seq, pushToUserID, v, "len:", len(user2PushMsg[v]))
|
||||
@@ -43,14 +42,14 @@ func (r *RPCServer) GetSingleUserMsgForPushPlatforms(operationID string, msgData
|
||||
return user2PushMsg
|
||||
}
|
||||
|
||||
func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserID string, platformID int) *sdk_ws.MsgDataList {
|
||||
func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdkws.MsgData, pushToUserID string, platformID int) *sdkws.MsgDataList {
|
||||
//msgData.MsgDataList = nil
|
||||
return &sdk_ws.MsgDataList{MsgDataList: []*sdk_ws.MsgData{msgData}}
|
||||
return &sdkws.MsgDataList{MsgDataList: []*sdkws.MsgData{msgData}}
|
||||
|
||||
//userConn := ws.getUserConn(pushToUserID, platformID)
|
||||
//if userConn == nil {
|
||||
// log.Debug(operationID, "userConn == nil")
|
||||
// return []*sdk_ws.MsgData{msgData}
|
||||
// return []*sdkws.MsgData{msgData}
|
||||
//}
|
||||
//
|
||||
//if msgData.Seq <= userConn.PushedMaxSeq {
|
||||
@@ -62,7 +61,7 @@ func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdk_ws.
|
||||
//if msgList == nil {
|
||||
// log.Debug(operationID, "GetSingleUserMsg msgList == nil", msgData.Seq, userConn.PushedMaxSeq)
|
||||
// userConn.PushedMaxSeq = msgData.Seq
|
||||
// return []*sdk_ws.MsgData{msgData}
|
||||
// return []*sdkws.MsgData{msgData}
|
||||
//}
|
||||
//msgList = append(msgList, msgData)
|
||||
//
|
||||
@@ -75,7 +74,7 @@ func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdk_ws.
|
||||
//return msgList
|
||||
}
|
||||
|
||||
func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, userID string) []*sdk_ws.MsgData {
|
||||
func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, userID string) []*sdkws.MsgData {
|
||||
seqList, err := r.GenPullSeqList(currentMsgSeq, operationID, userID)
|
||||
if err != nil {
|
||||
log.Error(operationID, "GenPullSeqList failed ", err.Error(), currentMsgSeq, userID)
|
||||
@@ -85,7 +84,7 @@ func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, u
|
||||
log.Error(operationID, "GenPullSeqList len == 0 ", currentMsgSeq, userID)
|
||||
return nil
|
||||
}
|
||||
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||
rpcReq := sdkws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = seqList
|
||||
rpcReq.UserID = userID
|
||||
rpcReq.OperationID = operationID
|
||||
@@ -108,8 +107,8 @@ func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, u
|
||||
return reply.List
|
||||
}
|
||||
|
||||
//func (r *RPCServer) GetBatchUserMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserIDList []string, platformID int) map[string][]*sdk_ws.MsgData {
|
||||
// user2PushMsg := make(map[string][]*sdk_ws.MsgData, 0)
|
||||
//func (r *RPCServer) GetBatchUserMsgForPush(operationID string, msgData *sdkws.MsgData, pushToUserIDList []string, platformID int) map[string][]*sdkws.MsgData {
|
||||
// user2PushMsg := make(map[string][]*sdkws.MsgData, 0)
|
||||
// for _, v := range pushToUserIDList {
|
||||
// user2PushMsg[v] = r.GetSingleUserMsgForPush(operationID, msgData, v, platformID)
|
||||
// }
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
cbApi "Open_IM/pkg/callback_struct"
|
||||
@@ -1,22 +0,0 @@
|
||||
package open_im_media
|
||||
|
||||
const (
|
||||
// Address gRPC服务地址
|
||||
Address = "127.0.0.1:11300"
|
||||
)
|
||||
|
||||
type Media struct {
|
||||
}
|
||||
|
||||
func NewMedia() *Media {
|
||||
return &Media{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
func (m *Media) CreateRoom(roomName string) (error, error) {
|
||||
return nil, nil
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -6,11 +6,10 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/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"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
@@ -78,15 +77,15 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
|
||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
||||
nReply := new(sdk_ws.GetMaxAndMinSeqResp)
|
||||
nReply := new(sdkws.GetMaxAndMinSeqResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSGetNewestSeq, m.OperationID)
|
||||
log.Info(m.OperationID, "argsValidate ", isPass, errCode, errMsg)
|
||||
if isPass {
|
||||
rpcReq := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
rpcReq.GroupIDList = data.(sdk_ws.GetMaxAndMinSeqReq).GroupIDList
|
||||
rpcReq := sdkws.GetMaxAndMinSeqReq{}
|
||||
rpcReq.GroupIDList = data.(sdkws.GetMaxAndMinSeqReq).GroupIDList
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
log.Debug(m.OperationID, "Ws call success to getMaxAndMinSeq", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.GetMaxAndMinSeqReq).GroupIDList)
|
||||
log.Debug(m.OperationID, "Ws call success to getMaxAndMinSeq", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdkws.GetMaxAndMinSeqReq).GroupIDList)
|
||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
@@ -115,7 +114,7 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *sdk_ws.GetMaxAndMinSeqResp) {
|
||||
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *sdkws.GetMaxAndMinSeqResp) {
|
||||
|
||||
b, _ := proto.Marshal(pb)
|
||||
mReply := Resp{
|
||||
@@ -133,15 +132,15 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *sdk_ws.GetMaxAndMinSeq
|
||||
|
||||
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr, string(m.Data))
|
||||
nReply := new(sdk_ws.PullMessageBySeqListResp)
|
||||
nReply := new(sdkws.PullMessageBySeqListResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList, m.OperationID)
|
||||
if isPass {
|
||||
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = data.(sdk_ws.PullMessageBySeqListReq).SeqList
|
||||
rpcReq := sdkws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = data.(sdkws.PullMessageBySeqListReq).SeqList
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
rpcReq.GroupSeqList = data.(sdk_ws.PullMessageBySeqListReq).GroupSeqList
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.PullMessageBySeqListReq).SeqList)
|
||||
rpcReq.GroupSeqList = data.(sdkws.PullMessageBySeqListReq).GroupSeqList
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdkws.PullMessageBySeqListReq).SeqList)
|
||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
@@ -169,7 +168,7 @@ 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) {
|
||||
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdkws.PullMessageBySeqListResp) {
|
||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
|
||||
c, _ := proto.Marshal(pb)
|
||||
mReply := Resp{
|
||||
@@ -229,7 +228,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
nReply := new(pbChat.SendMsgResp)
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg, m.OperationID)
|
||||
if isPass {
|
||||
data := pData.(sdk_ws.MsgData)
|
||||
data := pData.(sdkws.MsgData)
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: m.Token,
|
||||
OperationID: m.OperationID,
|
||||
@@ -265,7 +264,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
|
||||
}
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
||||
var mReplyData sdk_ws.UserSendMsgResp
|
||||
var mReplyData sdkws.UserSendMsgResp
|
||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||
mReplyData.SendTime = pb.GetSendTime()
|
||||
@@ -307,7 +306,7 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
return
|
||||
}
|
||||
signalResp.Payload = respPb.SignalResp.Payload
|
||||
msgData := sdk_ws.MsgData{}
|
||||
msgData := sdkws.MsgData{}
|
||||
utils.CopyStructFields(&msgData, respPb.MsgData)
|
||||
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), respPb.String())
|
||||
if respPb.IsPass {
|
||||
@@ -406,7 +405,7 @@ func SetTokenKicked(userID string, platformID int, operationID string) {
|
||||
func (ws *WServer) setUserDeviceBackground(conn *UserConn, m *Req) {
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WsSetBackgroundStatus, m.OperationID)
|
||||
if isPass {
|
||||
req := pData.(*sdk_ws.SetAppBackgroundStatusReq)
|
||||
req := pData.(*sdkws.SetAppBackgroundStatusReq)
|
||||
conn.IsBackground = req.IsBackground
|
||||
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, conn.IsBackground, conn.connID)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -6,9 +6,8 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
@@ -297,7 +296,7 @@ func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.Online
|
||||
SinglePushResult: singleUserResult,
|
||||
}, nil
|
||||
}
|
||||
func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (bytes.Buffer, error) {
|
||||
func (r *RPCServer) encodeWsData(wsData *sdkws.MsgData, operationID string) (bytes.Buffer, error) {
|
||||
log.Debug(operationID, "encodeWsData begin", wsData.String())
|
||||
msgBytes, err := proto.Marshal(wsData)
|
||||
if err != nil {
|
||||
@@ -4,13 +4,13 @@
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/5/21 15:29).
|
||||
*/
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package logic
|
||||
package msgtransfer
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
@@ -1,4 +1,4 @@
|
||||
package logic
|
||||
package msgtransfer
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
+4
-6
@@ -1,15 +1,13 @@
|
||||
package logic
|
||||
package msgtransfer
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mongo"
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbMsg "Open_IM/pkg/proto/msg"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"github.com/Shopify/sarama"
|
||||
@@ -90,9 +88,9 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
var reactionExtensionList = make(map[string]*server_api_params.KeyValue)
|
||||
var reactionExtensionList = make(map[string]*sdkws.KeyValue)
|
||||
for _, v := range notification.SuccessReactionExtensionList {
|
||||
reactionExtensionList[v.TypeKey] = &server_api_params.KeyValue{
|
||||
reactionExtensionList[v.TypeKey] = &sdkws.KeyValue{
|
||||
TypeKey: v.TypeKey,
|
||||
Value: v.Value,
|
||||
LatestUpdateTime: v.LatestUpdateTime,
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package logic
|
||||
package msgtransfer
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbMsg "Open_IM/pkg/proto/msg"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"Open_IM/pkg/utils"
|
||||
@@ -164,8 +163,8 @@ func (och *OnlineHistoryRedisConsumerHandler) SendMessageToMongoCH(aggregationID
|
||||
// }
|
||||
// for _, v := range msgList {
|
||||
// if v.MsgData.ContentType == constant.DeleteMessageNotification {
|
||||
// tips := server_api_params.TipsComm{}
|
||||
// DeleteMessageTips := server_api_params.DeleteMessageTips{}
|
||||
// tips := sdkws.TipsComm{}
|
||||
// DeleteMessageTips := sdkws.DeleteMessageTips{}
|
||||
// err := proto.Unmarshal(v.MsgData.Content, &tips)
|
||||
// if err != nil {
|
||||
// log.NewError(triggerID, "tips unmarshal err:", err.Error(), v.String())
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
package logic
|
||||
package msgtransfer
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbMsg "Open_IM/pkg/proto/msg"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
@@ -18,10 +18,10 @@ type OnlineHistoryMongoConsumerHandler struct {
|
||||
historyConsumerGroup *kfk.MConsumerGroup
|
||||
}
|
||||
|
||||
func (och *OnlineHistoryMongoConsumerHandler) Init() {
|
||||
och.msgHandle = make(map[string]fcb)
|
||||
och.msgHandle[config.Config.Kafka.MsgToMongo.Topic] = och.handleChatWs2Mongo
|
||||
och.historyConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
|
||||
func (mc *OnlineHistoryMongoConsumerHandler) Init() {
|
||||
mc.msgHandle = make(map[string]fcb)
|
||||
mc.msgHandle[config.Config.Kafka.MsgToMongo.Topic] = mc.handleChatWs2Mongo
|
||||
mc.historyConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
|
||||
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToMongo.Topic},
|
||||
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo)
|
||||
|
||||
@@ -46,8 +46,8 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(cMsg *sarama.Con
|
||||
}
|
||||
for _, v := range msgFromMQ.MessageList {
|
||||
if v.MsgData.ContentType == constant.DeleteMessageNotification {
|
||||
tips := server_api_params.TipsComm{}
|
||||
DeleteMessageTips := server_api_params.DeleteMessageTips{}
|
||||
tips := sdkws.TipsComm{}
|
||||
DeleteMessageTips := sdkws.DeleteMessageTips{}
|
||||
err := proto.Unmarshal(v.MsgData.Content, &tips)
|
||||
if err != nil {
|
||||
log.NewError(msgFromMQ.TriggerID, "tips unmarshal err:", err.Error(), v.String())
|
||||
@@ -68,13 +68,13 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(cMsg *sarama.Con
|
||||
func (OnlineHistoryMongoConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
func (OnlineHistoryMongoConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
|
||||
func (och *OnlineHistoryMongoConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
||||
func (mc *OnlineHistoryMongoConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
||||
claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
|
||||
log.NewDebug("", "online new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
|
||||
for msg := range claim.Messages() {
|
||||
log.NewDebug("", "kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value), "key", string(msg.Key))
|
||||
if len(msg.Value) != 0 {
|
||||
och.msgHandle[msg.Topic](msg, string(msg.Key), sess)
|
||||
mc.msgHandle[msg.Topic](msg, string(msg.Key), sess)
|
||||
} else {
|
||||
log.Error("", "mongo msg get from kafka but is nil", msg.Key)
|
||||
}
|
||||
+13
-1
@@ -4,7 +4,7 @@
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/5/11 15:37).
|
||||
*/
|
||||
package logic
|
||||
package msgtransfer
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -98,3 +98,15 @@ func (pc *PersistentConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSessi
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
1. 请求1 group Rpc 2. 请求2 发消息 sendMsg rpc
|
||||
1 更改数据库
|
||||
|
||||
2. 删除哈希缓存
|
||||
检测到哈希变了, 群成员还没来得及删除,有问题
|
||||
3. 删除群成员缓存
|
||||
|
||||
4. 删除对应群成员加群缓存
|
||||
|
||||
5. 删除数量缓存
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('open-im,www.open-im.io').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/5/27 11:24).
|
||||
*/
|
||||
package content_struct
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Content struct {
|
||||
IsDisplay int32 `json:"isDisplay"`
|
||||
ID string `json:"id"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
func NewContentStructString(isDisplay int32, ID string, text string) string {
|
||||
c := Content{IsDisplay: isDisplay, ID: ID, Text: text}
|
||||
return c.contentToString()
|
||||
}
|
||||
|
||||
func (c *Content) contentToString() string {
|
||||
data, _ := json.Marshal(c)
|
||||
dataString := string(data)
|
||||
return dataString
|
||||
}
|
||||
|
||||
type groupMemberFullInfo struct {
|
||||
GroupId string `json:"groupID"`
|
||||
UserId string `json:"userId"`
|
||||
Role int `json:"role"`
|
||||
JoinTime uint64 `json:"joinTime"`
|
||||
NickName string `json:"nickName"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
}
|
||||
|
||||
type AgreeOrRejectGroupMember struct {
|
||||
GroupId string `json:"groupID"`
|
||||
UserId string `json:"userId"`
|
||||
Role int `json:"role"`
|
||||
JoinTime uint64 `json:"joinTime"`
|
||||
NickName string `json:"nickName"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
type AtTextContent struct {
|
||||
Text string `json:"text"`
|
||||
AtUserList []string `json:"atUserList"`
|
||||
IsAtSelf bool `json:"isAtSelf"`
|
||||
}
|
||||
|
||||
type CreateGroupSysMsg struct {
|
||||
uIdCreator string `creatorUid`
|
||||
initMemberList []groupMemberFullInfo `json: initMemberList`
|
||||
CreateTime uint64 `json:"CreateTime"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type NotificationContent struct {
|
||||
IsDisplay int32 `json:"isDisplay"`
|
||||
DefaultTips string `json:"defaultTips"`
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
|
||||
func (c *NotificationContent) ContentToString() string {
|
||||
data, _ := json.Marshal(c)
|
||||
dataString := string(data)
|
||||
return dataString
|
||||
}
|
||||
|
||||
type KickGroupMemberApiReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
UidList []string `json:"uidList"`
|
||||
Reason string `json:"reason"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
func NewCreateGroupSysMsgString(create *CreateGroupSysMsg, text string) string {
|
||||
create.Text = text
|
||||
jstring, _ := json.Marshal(create)
|
||||
|
||||
return string(jstring)
|
||||
}
|
||||
@@ -35,24 +35,24 @@ func (j *JPush) SetAlias(cid, alias string) (resp string, err error) {
|
||||
|
||||
func (j *JPush) Push(accounts []string, title, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
||||
|
||||
var pf requestBody.Platform
|
||||
var pf requestbody.Platform
|
||||
pf.SetAll()
|
||||
var au requestBody.Audience
|
||||
var au requestbody.Audience
|
||||
au.SetAlias(accounts)
|
||||
var no requestBody.Notification
|
||||
var no requestbody.Notification
|
||||
|
||||
var extras requestBody.Extras
|
||||
var extras requestbody.Extras
|
||||
if opts.Signal.ClientMsgID != "" {
|
||||
extras.ClientMsgID = opts.Signal.ClientMsgID
|
||||
}
|
||||
no.IOSEnableMutableContent()
|
||||
no.SetExtras(extras)
|
||||
no.SetAlert(title)
|
||||
var me requestBody.Message
|
||||
var me requestbody.Message
|
||||
me.SetMsgContent(detailContent)
|
||||
var o requestBody.Options
|
||||
var o requestbody.Options
|
||||
o.SetApnsProduction(config.Config.IOSPush.Production)
|
||||
var po requestBody.PushObj
|
||||
var po requestbody.PushObj
|
||||
po.SetPlatform(&pf)
|
||||
po.SetAudience(&au)
|
||||
po.SetNotification(&no)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestBody
|
||||
package requestbody
|
||||
|
||||
const (
|
||||
TAG = "tag"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestBody
|
||||
package requestbody
|
||||
|
||||
type Message struct {
|
||||
MsgContent string `json:"msg_content"`
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestBody
|
||||
package requestbody
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestBody
|
||||
package requestbody
|
||||
|
||||
type Options struct {
|
||||
ApnsProduction bool `json:"apns_production"`
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestBody
|
||||
package requestbody
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestBody
|
||||
package requestbody
|
||||
|
||||
type PushObj struct {
|
||||
Platform interface{} `json:"platform"`
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
common "Open_IM/pkg/proto/sdk_ws"
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
http2 "net/http"
|
||||
)
|
||||
|
||||
@@ -26,23 +26,21 @@ func newGetuiClient() *MobPush {
|
||||
}
|
||||
|
||||
func (j *MobPush) Push(accounts []string, alert, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
||||
|
||||
var target requestParams.PushTarget
|
||||
|
||||
var target requestparams.PushTarget
|
||||
target.SetAlias(accounts)
|
||||
target.SetTarget(2)
|
||||
|
||||
var no requestParams.PushNotify
|
||||
var no requestparams.PushNotify
|
||||
no.SetType(1)
|
||||
no.SetIosProduction(1)
|
||||
no.SetPlats([]int{1, 2})
|
||||
no.SetContent(alert)
|
||||
|
||||
var forward requestParams.PushForward
|
||||
var forward requestparams.PushForward
|
||||
forward.SetNextType(2)
|
||||
forward.SetScheme(config.Config.Push.Mob.Scheme)
|
||||
|
||||
var po requestParams.PushObj
|
||||
var po requestparams.PushObj
|
||||
po.SetSource("webapi")
|
||||
po.SetAppkey(config.Config.Push.Mob.AppKey)
|
||||
po.SetPushTarget(&target)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestParams
|
||||
package requestparams
|
||||
|
||||
type PushForward struct {
|
||||
NextType int `json:"nextType"`
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestParams
|
||||
package requestparams
|
||||
|
||||
type PushNotify struct {
|
||||
Plats []int `json:"plats,omitempty"`
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestParams
|
||||
package requestparams
|
||||
|
||||
type PushObj struct {
|
||||
Source interface{} `json:"source"`
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package requestParams
|
||||
package requestparams
|
||||
|
||||
type PushTarget struct {
|
||||
Target interface{} `json:"target,omitempty"`
|
||||
@@ -1,62 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
b64 "encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Auther struct {
|
||||
AccessID string
|
||||
SecretKey string
|
||||
}
|
||||
|
||||
var UseSignAuthored = true
|
||||
|
||||
func (a *Auther) Auth(req *http.Request, useSignAuthored bool, auth Auther, reqBody string) {
|
||||
|
||||
if useSignAuthored {
|
||||
now := time.Now()
|
||||
timeStamp := now.Unix()
|
||||
req.Header.Add("AccessId", auth.AccessID)
|
||||
req.Header.Add("TimeStamp", strconv.Itoa(int(timeStamp)))
|
||||
sign := GenSign(uint64(timeStamp), auth.AccessID, auth.SecretKey, reqBody)
|
||||
req.Header.Add("Sign", sign)
|
||||
} else {
|
||||
author := makeAuthHeader(a.AccessID, a.SecretKey)
|
||||
//log.Printf("author string:%v", author)
|
||||
req.Header.Add("Authorization", author)
|
||||
}
|
||||
//req.Header.Add("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
func makeAuthHeader(appID, secretKey string) string {
|
||||
base64Str := base64.StdEncoding.EncodeToString(
|
||||
[]byte(
|
||||
fmt.Sprintf("%s:%s", appID, secretKey),
|
||||
),
|
||||
)
|
||||
return fmt.Sprintf("Basic %s", base64Str)
|
||||
}
|
||||
|
||||
func GenSign(timeStamp uint64, accessId string, secretKey, requestBody string) string {
|
||||
signBody := strconv.Itoa(int(timeStamp)) + accessId + requestBody
|
||||
// Create a new HMAC by defining the hash type and the key (as byte array)
|
||||
h := hmac.New(sha256.New, []byte(secretKey))
|
||||
// Write Data to it
|
||||
h.Write([]byte(signBody))
|
||||
|
||||
// Get result and encode as hexadecimal string
|
||||
sha := hex.EncodeToString(h.Sum(nil))
|
||||
//fmt.Println()
|
||||
//fmt.Println("timeStamp: " + strconv.Itoa(int(timeStamp)) + " accessID:" + accessId + " body:" + requestBody)
|
||||
sEnc := b64.StdEncoding.EncodeToString([]byte(sha))
|
||||
//fmt.Println("final Result " + sEnc)
|
||||
return sEnc
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func New() *http.Client {
|
||||
return &http.Client{
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 100,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
DisableCompression: false,
|
||||
DisableKeepAlives: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func PushAndGetResult(pushReq *http.Request) {
|
||||
c := &http.Client{}
|
||||
rsp, err := c.Do(pushReq)
|
||||
fmt.Println()
|
||||
if err != nil {
|
||||
//fmt.Printf("http err:%v", err)
|
||||
return
|
||||
}
|
||||
defer rsp.Body.Close()
|
||||
body, err := ioutil.ReadAll(rsp.Body)
|
||||
//fmt.Printf("http ReadAll err:%v, body:%v ", err, string(body))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
r := &tpns.CommonRsp{}
|
||||
json.Unmarshal(body, r)
|
||||
//fmt.Printf("push result: %+v", r)
|
||||
}
|
||||
|
||||
func UploadFile(req *http.Request) (int, error) {
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return 0, fmt.Errorf("response error, status: %s, body: %s", resp.Status, string(body))
|
||||
}
|
||||
|
||||
type uploadResponse struct {
|
||||
RetCode int `json:"retCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
UploadId int `json:"uploadId"`
|
||||
}
|
||||
|
||||
var ur uploadResponse
|
||||
if err := json.Unmarshal(body, &ur); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if ur.RetCode != 0 {
|
||||
return 0, fmt.Errorf("response with %d:%s", ur.RetCode, ur.ErrMsg)
|
||||
}
|
||||
return ur.UploadId, nil
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package common
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func ToJson(v interface{}) string {
|
||||
bs, _ := json.Marshal(v)
|
||||
return string(bs)
|
||||
}
|
||||
@@ -1,256 +0,0 @@
|
||||
package tpns
|
||||
|
||||
type CommonRspEnv string
|
||||
|
||||
const (
|
||||
// EnvProd
|
||||
EnvProd CommonRspEnv = "product"
|
||||
// EnvDev
|
||||
EnvDev CommonRspEnv = "dev"
|
||||
)
|
||||
|
||||
type CommonRsp struct {
|
||||
// TODO: doc this
|
||||
Seq int64 `json:"seq"`
|
||||
|
||||
PushID string `json:"push_id"`
|
||||
|
||||
RetCode int `json:"ret_code"`
|
||||
|
||||
Environment CommonRspEnv `json:"environment"`
|
||||
|
||||
ErrMsg string `json:"err_msg,omitempty"`
|
||||
|
||||
Result map[string]string `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type AudienceType string
|
||||
|
||||
const (
|
||||
AdAll AudienceType = "all"
|
||||
|
||||
AdTag AudienceType = "tag"
|
||||
|
||||
AdToken AudienceType = "token"
|
||||
|
||||
AdTokenList AudienceType = "token_list"
|
||||
|
||||
AdAccount AudienceType = "account"
|
||||
|
||||
AdAccountList AudienceType = "account_list"
|
||||
|
||||
AdPackageAccount AudienceType = "package_account_push"
|
||||
|
||||
AdPackageToken AudienceType = "package_token_push"
|
||||
)
|
||||
|
||||
// MessageType push API message_type
|
||||
type MessageType string
|
||||
|
||||
const (
|
||||
MsgTypeNotify MessageType = "notify"
|
||||
|
||||
MsgTypeMessage MessageType = "message"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
AudienceType AudienceType `json:"audience_type"`
|
||||
|
||||
Message Message `json:"message"`
|
||||
|
||||
MessageType MessageType `json:"message_type"`
|
||||
|
||||
Tag []TagRule `json:"tag_rules,omitempty"`
|
||||
|
||||
TokenList []string `json:"token_list,omitempty"`
|
||||
|
||||
AccountList []string `json:"account_list,omitempty"`
|
||||
|
||||
Environment CommonRspEnv `json:"environment,omitempty"`
|
||||
|
||||
UploadId int `json:"upload_id,omitempty"`
|
||||
|
||||
ExpireTime int `json:"expire_time,omitempty"`
|
||||
|
||||
SendTime string `json:"send_time,omitempty"`
|
||||
|
||||
MultiPkg bool `json:"multi_pkg,omitempty"`
|
||||
|
||||
PlanId string `json:"plan_id,omitempty"`
|
||||
|
||||
AccountPushType int `json:"account_push_type,omitempty"`
|
||||
|
||||
PushSpeed int `json:"push_speed,omitempty"`
|
||||
|
||||
CollapseId int `json:"collapse_id"`
|
||||
|
||||
TPNSOnlinePushType int `json:"tpns_online_push_type"`
|
||||
|
||||
ChannelRules []*ChannelDistributeRule `json:"channel_rules,omitempty"`
|
||||
|
||||
LoopParam *PushLoopParam `json:"loop_param,omitempty"`
|
||||
ForceCollapse bool `json:"force_collapse"`
|
||||
}
|
||||
|
||||
type TagListOperation string
|
||||
|
||||
type ChannelDistributeRule struct {
|
||||
ChannelName string `json:"channel"`
|
||||
Disable bool `json:"disable"`
|
||||
}
|
||||
|
||||
type PushLoopParam struct {
|
||||
StartDate string `json:"startDate"`
|
||||
|
||||
EndDate string `json:"endDate"`
|
||||
|
||||
LoopType PushLoopType `json:"loopType"`
|
||||
|
||||
LoopDayIndexs []uint32 `json:"loopDayIndexs"`
|
||||
|
||||
DayTimes []string `json:"dayTimes"`
|
||||
}
|
||||
|
||||
type PushLoopType int32
|
||||
|
||||
const (
|
||||
TagListOpAnd TagListOperation = "AND"
|
||||
|
||||
TagListOpOr TagListOperation = "OR"
|
||||
)
|
||||
|
||||
type TagType string
|
||||
|
||||
const (
|
||||
XGAutoProvince TagType = "xg_auto_province"
|
||||
XGAutoActive TagType = "xg_auto_active"
|
||||
XGUserDefine TagType = "xg_user_define"
|
||||
XGAutoVersion TagType = "xg_auto_version"
|
||||
XGAutoSdkversion TagType = "xg_auto_sdkversion"
|
||||
XGAutoDevicebrand TagType = "xg_auto_devicebrand"
|
||||
XGAutoDeviceversion TagType = "xg_auto_deviceversion"
|
||||
XGAutoCountry TagType = "xg_auto_country"
|
||||
)
|
||||
|
||||
type TagRule struct {
|
||||
TagItems []TagItem `json:"tag_items"`
|
||||
|
||||
IsNot bool `json:"is_not"`
|
||||
|
||||
Operator TagListOperation `json:"operator"`
|
||||
}
|
||||
|
||||
type TagItem struct {
|
||||
// 标签
|
||||
Tags []string `json:"tags"`
|
||||
IsNot bool `json:"is_not"`
|
||||
TagsOperator TagListOperation `json:"tags_operator"`
|
||||
ItemsOperator TagListOperation `json:"items_operator"`
|
||||
TagType TagType `json:"tag_type"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
|
||||
AcceptTime []AcceptTimeItem `json:"accept_time,omitempty"`
|
||||
|
||||
Android *AndroidParams `json:"android,omitempty"`
|
||||
|
||||
IOS *IOSParams `json:"ios,omitempty"`
|
||||
|
||||
ThreadId string `json:"thread_id,omitempty"`
|
||||
|
||||
ThreadSumtext string `json:"thread_sumtext,omitempty"`
|
||||
|
||||
XGMediaResources string `json:"xg_media_resources,omitempty"`
|
||||
|
||||
XGMediaAudioResources string `json:"xg_media_audio_resources,omitempty"`
|
||||
}
|
||||
|
||||
type AcceptTimeItem struct {
|
||||
Start HourAndMin `json:"start,omitempty"`
|
||||
End HourAndMin `json:"end,omitempty"`
|
||||
}
|
||||
|
||||
type HourAndMin struct {
|
||||
Hour string `json:"hour,omitempty"`
|
||||
Min string `json:"min,omitempty"`
|
||||
}
|
||||
|
||||
type AndroidParams struct {
|
||||
BuilderId *int `json:"builder_id,omitempty"`
|
||||
|
||||
Ring *int `json:"ring,omitempty"`
|
||||
|
||||
RingRaw string `json:"ring_raw,omitempty"`
|
||||
|
||||
Vibrate *int `json:"vibrate,omitempty"`
|
||||
|
||||
Lights *int `json:"lights,omitempty"`
|
||||
|
||||
Clearable *int `json:"clearable,omitempty"`
|
||||
|
||||
IconType *int `json:"icon_type"`
|
||||
|
||||
IconRes string `json:"icon_res,omitempty"`
|
||||
|
||||
StyleId *int `json:"style_id,omitempty"`
|
||||
|
||||
SmallIcon string `json:"small_icon,omitempty"`
|
||||
|
||||
Action *Action `json:"action,omitempty"`
|
||||
|
||||
CustomContent string `json:"custom_content,omitempty"`
|
||||
|
||||
ShowType *int `json:"show_type,omitempty"`
|
||||
|
||||
NChId string `json:"n_ch_id,omitempty"`
|
||||
|
||||
NChName string `json:"n_ch_name,omitempty"`
|
||||
|
||||
HwChId string `json:"hw_ch_id,omitempty"`
|
||||
|
||||
XmChId string `json:"xm_ch_id,omitempty"`
|
||||
|
||||
OppoChId string `json:"oppo_ch_id,omitempty"`
|
||||
|
||||
VivoChId string `json:"vivo_ch_id,omitempty"`
|
||||
|
||||
BadgeType *int `json:"badge_type,omitempty"`
|
||||
|
||||
IconColor *int `json:"icon_color,omitempty"`
|
||||
}
|
||||
|
||||
type Action struct {
|
||||
ActionType *int `json:"action_type,omitempty"`
|
||||
Activity string `json:"activity"`
|
||||
AtyAttr AtyAttr `json:"aty_attr,omitempty"`
|
||||
Intent string `json:"intent"`
|
||||
Browser Browser `json:"browser,omitempty"`
|
||||
}
|
||||
|
||||
type Browser struct {
|
||||
Url string `json:"url,omitempty"`
|
||||
Confirm *int `json:"confirm,omitempty"`
|
||||
}
|
||||
|
||||
type AtyAttr struct {
|
||||
AttrIf *int `json:"if,omitempty"`
|
||||
Pf *int `json:"pf,omitempty"`
|
||||
}
|
||||
|
||||
type IOSParams struct {
|
||||
Aps *Aps `json:"aps,omitempty"`
|
||||
|
||||
CustomContent string `json:"custom_content,omitempty"`
|
||||
}
|
||||
|
||||
type Aps struct {
|
||||
Alert map[string]string `json:"alert,omitempty"`
|
||||
BadgeType *int `json:"badge_type,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
ContentAvailableInt *int `json:"content-available,omitempty"`
|
||||
MutableContent *int `json:"mutable-content,omitempty"`
|
||||
Sound string `json:"sound,omitempty"`
|
||||
}
|
||||
@@ -1,403 +0,0 @@
|
||||
package req
|
||||
|
||||
import (
|
||||
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var PushURL = "https://api.tpns.tencent.com/v3/push/app"
|
||||
|
||||
//var PushURL = "https://test.api.tpns.tencent.com/v3/push/app"
|
||||
|
||||
func URL(url string) {
|
||||
PushURL = url
|
||||
}
|
||||
|
||||
type ReqOpt func(*tpns.Request)
|
||||
|
||||
func NewPush(req *tpns.Request, opts ...ReqOpt) (*http.Request, string, error) {
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewUploadFileRequest(host string, file string) (*http.Request, error) {
|
||||
fp, err := os.Open(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer fp.Close()
|
||||
body := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(body)
|
||||
part, err := writer.CreateFormFile("file", filepath.Base(fp.Name()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
io.Copy(part, fp)
|
||||
writer.Close()
|
||||
url := host + "/v3/push/package/upload"
|
||||
req, err := http.NewRequest("POST", url, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Add("Content-Type", writer.FormDataContentType())
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func NewSingleAccountPush(
|
||||
message tpns.Message,
|
||||
account string,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdAccountList,
|
||||
AccountList: []string{account},
|
||||
Message: message,
|
||||
}
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewListAccountPush(
|
||||
accounts []string, message tpns.Message,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdAccountList,
|
||||
AccountList: accounts,
|
||||
Message: message,
|
||||
Environment: tpns.EnvDev,
|
||||
}
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewTokenPush(
|
||||
tokens []string, message tpns.Message,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdTokenList,
|
||||
TokenList: tokens,
|
||||
Message: message,
|
||||
Environment: tpns.EnvProd,
|
||||
}
|
||||
//fmt.Printf("reqBody :%v", common.ToJson(req))
|
||||
//fmt.Println()
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewTagsPush(
|
||||
tagList []tpns.TagRule, message tpns.Message,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdTag,
|
||||
Tag: tagList,
|
||||
Message: message,
|
||||
}
|
||||
//fmt.Printf("reqBody :%v", common.ToJson(req))
|
||||
//fmt.Println()
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewAllPush(
|
||||
message tpns.Message,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdAll,
|
||||
Message: message,
|
||||
}
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewAccountPackagePush(
|
||||
message tpns.Message,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdPackageAccount,
|
||||
Message: message,
|
||||
}
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewTokenPackagePush(
|
||||
message tpns.Message,
|
||||
opts ...ReqOpt,
|
||||
) (*http.Request, string, error) {
|
||||
req := &tpns.Request{
|
||||
MessageType: tpns.MsgTypeNotify,
|
||||
AudienceType: tpns.AdPackageToken,
|
||||
Message: message,
|
||||
}
|
||||
return NewPushReq(req, opts...)
|
||||
}
|
||||
|
||||
func NewPushReq(req *tpns.Request, opts ...ReqOpt) (request *http.Request, reqBody string, err error) {
|
||||
for _, opt := range opts {
|
||||
opt(req)
|
||||
}
|
||||
bodyBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
reqBody = string(bodyBytes)
|
||||
//fmt.Printf("NewPushReq req:%v", reqBody)
|
||||
request, err = http.NewRequest("POST", PushURL, bytes.NewReader(bodyBytes))
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
request.Header.Add("Content-Type", "application/json")
|
||||
return
|
||||
}
|
||||
|
||||
func EnvProd() ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Environment = tpns.EnvProd
|
||||
}
|
||||
}
|
||||
|
||||
func EnvDev() ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Environment = tpns.EnvDev
|
||||
}
|
||||
}
|
||||
|
||||
func Title(t string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Title = t
|
||||
if r.Message.IOS != nil {
|
||||
if r.Message.IOS.Aps != nil {
|
||||
r.Message.IOS.Aps.Alert["title"] = t
|
||||
} else {
|
||||
r.Message.IOS.Aps = &tpns.Aps{
|
||||
Alert: map[string]string{"title": t},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r.Message.IOS = &tpns.IOSParams{
|
||||
Aps: &tpns.Aps{
|
||||
Alert: map[string]string{"title": t},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Content(c string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Content = c
|
||||
if r.Message.IOS != nil {
|
||||
if r.Message.IOS.Aps != nil {
|
||||
r.Message.IOS.Aps.Alert["body"] = c
|
||||
} else {
|
||||
r.Message.IOS.Aps = &tpns.Aps{
|
||||
Alert: map[string]string{"body": c},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r.Message.IOS = &tpns.IOSParams{
|
||||
Aps: &tpns.Aps{
|
||||
Alert: map[string]string{"body": c},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Ring(ring *int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.Ring = ring
|
||||
}
|
||||
}
|
||||
|
||||
func RingRaw(rr string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.RingRaw = rr
|
||||
}
|
||||
}
|
||||
|
||||
func Vibrate(v *int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.Vibrate = v
|
||||
}
|
||||
}
|
||||
|
||||
func Lights(l *int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.Lights = l
|
||||
}
|
||||
}
|
||||
|
||||
func Clearable(c *int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.Clearable = c
|
||||
}
|
||||
}
|
||||
|
||||
func IconType(it *int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.IconType = it
|
||||
}
|
||||
}
|
||||
|
||||
func IconRes(ir string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.IconRes = ir
|
||||
}
|
||||
}
|
||||
|
||||
func AndroidCustomContent(ct string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.Android.CustomContent = ct
|
||||
}
|
||||
}
|
||||
|
||||
func Aps(aps *tpns.Aps) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message.IOS.Aps = aps
|
||||
}
|
||||
}
|
||||
|
||||
func AudienceType(at tpns.AudienceType) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.AudienceType = at
|
||||
}
|
||||
}
|
||||
|
||||
func Message(m tpns.Message) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Message = m
|
||||
}
|
||||
}
|
||||
|
||||
func TokenList(tl []string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.TokenList = tl
|
||||
}
|
||||
}
|
||||
|
||||
func TokenListAdd(t string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
if r.TokenList != nil {
|
||||
r.TokenList = append(r.TokenList, t)
|
||||
} else {
|
||||
r.TokenList = []string{t}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func AccountList(al []string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.AccountList = al
|
||||
}
|
||||
}
|
||||
|
||||
//ChannelDistributeRules
|
||||
func AddChannelRules(ChannelRules []*tpns.ChannelDistributeRule) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.ChannelRules = ChannelRules
|
||||
}
|
||||
}
|
||||
|
||||
//ChannelDistributeRules
|
||||
func AddLoopParam(loopParam *tpns.PushLoopParam) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.LoopParam = loopParam
|
||||
}
|
||||
}
|
||||
|
||||
func AccountListAdd(a string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
if r.AccountList != nil {
|
||||
r.AccountList = append(r.AccountList, a)
|
||||
} else {
|
||||
r.AccountList = []string{a}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func MessageType(t tpns.MessageType) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.MessageType = t
|
||||
}
|
||||
}
|
||||
|
||||
func AddMultiPkg(multipPkg bool) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.MultiPkg = multipPkg
|
||||
}
|
||||
}
|
||||
|
||||
func AddForceCollapse(forceCollapse bool) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.ForceCollapse = forceCollapse
|
||||
}
|
||||
}
|
||||
|
||||
func AddTPNSOnlinePushType(onlinePushType int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.TPNSOnlinePushType = onlinePushType
|
||||
}
|
||||
}
|
||||
|
||||
func AddCollapseId(collapseId int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.CollapseId = collapseId
|
||||
}
|
||||
}
|
||||
|
||||
func AddPushSpeed(pushSpeed int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.PushSpeed = pushSpeed
|
||||
}
|
||||
}
|
||||
|
||||
func AddAccountPushType(accountPushType int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.AccountPushType = accountPushType
|
||||
}
|
||||
}
|
||||
|
||||
func AddPlanId(planId string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.PlanId = planId
|
||||
}
|
||||
}
|
||||
|
||||
func AddSendTime(sendTime string) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.SendTime = sendTime
|
||||
}
|
||||
}
|
||||
|
||||
func AddExpireTime(expireTime int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.ExpireTime = expireTime
|
||||
}
|
||||
}
|
||||
|
||||
func AddUploadId(UploadId int) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.UploadId = UploadId
|
||||
}
|
||||
}
|
||||
|
||||
func AddEnvironment(Environment tpns.CommonRspEnv) ReqOpt {
|
||||
return func(r *tpns.Request) {
|
||||
r.Environment = Environment
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package admin_cms
|
||||
package admincms
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
common "Open_IM/pkg/proto/sdk_ws"
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
|
||||
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
package fault_tolerant
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/middleware"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/OpenIMSDK/getcdv3"
|
||||
"google.golang.org/grpc"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetConfigConn(serviceName string, operationID string) *grpc.ClientConn {
|
||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
||||
var err error
|
||||
if config.Config.RpcRegisterIP == "" {
|
||||
rpcRegisterIP, err = utils.GetLocalIP()
|
||||
if err != nil {
|
||||
log.Error(operationID, "GetLocalIP failed ", err.Error())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var configPortList []int
|
||||
//1
|
||||
if config.Config.RpcRegisterName.OpenImUserName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImUserPort
|
||||
}
|
||||
//2
|
||||
if config.Config.RpcRegisterName.OpenImFriendName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImFriendPort
|
||||
}
|
||||
//3
|
||||
if config.Config.RpcRegisterName.OpenImMsgName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImMessagePort
|
||||
}
|
||||
//4
|
||||
if config.Config.RpcRegisterName.OpenImPushName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImPushPort
|
||||
}
|
||||
//5
|
||||
if config.Config.RpcRegisterName.OpenImRelayName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImMessageGatewayPort
|
||||
}
|
||||
//6
|
||||
if config.Config.RpcRegisterName.OpenImGroupName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImGroupPort
|
||||
}
|
||||
//7
|
||||
if config.Config.RpcRegisterName.OpenImAuthName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImAuthPort
|
||||
}
|
||||
//10
|
||||
if config.Config.RpcRegisterName.OpenImOfficeName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImOfficePort
|
||||
}
|
||||
//11
|
||||
if config.Config.RpcRegisterName.OpenImOrganizationName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImOrganizationPort
|
||||
}
|
||||
//12
|
||||
if config.Config.RpcRegisterName.OpenImConversationName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImConversationPort
|
||||
}
|
||||
//13
|
||||
if config.Config.RpcRegisterName.OpenImCacheName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImCachePort
|
||||
}
|
||||
//14
|
||||
if config.Config.RpcRegisterName.OpenImRealTimeCommName == serviceName {
|
||||
configPortList = config.Config.RpcPort.OpenImRealTimeCommPort
|
||||
}
|
||||
if len(configPortList) == 0 {
|
||||
log.Error(operationID, "len(configPortList) == 0 ")
|
||||
return nil
|
||||
}
|
||||
target := rpcRegisterIP + ":" + utils.Int32ToString(int32(configPortList[0]))
|
||||
log.Info(operationID, "rpcRegisterIP ", rpcRegisterIP, " port ", configPortList, " grpc target: ", target, " serviceName: ", serviceName)
|
||||
conn, err := grpc.Dial(target, grpc.WithInsecure(), grpc.WithUnaryInterceptor(middleware.RpcClientInterceptor))
|
||||
if err != nil {
|
||||
log.Error(operationID, "grpc.Dail failed ", err.Error())
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), serviceName, conn)
|
||||
return conn
|
||||
}
|
||||
|
||||
func GetDefaultConn(serviceName string, operationID string) (*grpc.ClientConn, error) {
|
||||
con := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), serviceName, operationID, config.Config.Etcd.UserName, config.Config.Etcd.Password)
|
||||
if con != nil {
|
||||
return con, nil
|
||||
}
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "conn is nil !!!!!", serviceName)
|
||||
con = GetConfigConn(serviceName, operationID)
|
||||
return con, nil
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package group
|
||||
import (
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package group
|
||||
|
||||
import (
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -13,34 +13,34 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetPublicUserInfoOne(ctx context.Context, userID string) (*sdk_ws.PublicUserInfo, error) {
|
||||
func GetPublicUserInfoOne(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
|
||||
return nil, errors.New("todo")
|
||||
}
|
||||
|
||||
func GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.UserInfo, error) {
|
||||
func GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
|
||||
return nil, errors.New("todo")
|
||||
}
|
||||
|
||||
func GetUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.UserInfo, error) {
|
||||
func GetUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||
users, err := GetUsersInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.SliceToMap(users, func(e *sdk_ws.UserInfo) string {
|
||||
return utils.SliceToMap(users, func(e *sdkws.UserInfo) string {
|
||||
return e.UserID
|
||||
}), nil
|
||||
}
|
||||
|
||||
func GetPublicUserInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.PublicUserInfo, error) {
|
||||
func GetPublicUserInfo(ctx context.Context, userIDs []string) ([]*sdkws.PublicUserInfo, error) {
|
||||
return nil, errors.New("todo")
|
||||
}
|
||||
|
||||
func GetPublicUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.PublicUserInfo, error) {
|
||||
func GetPublicUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.PublicUserInfo, error) {
|
||||
users, err := GetPublicUserInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.SliceToMap(users, func(e *sdk_ws.PublicUserInfo) string {
|
||||
return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string {
|
||||
return e.UserID
|
||||
}), nil
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"Open_IM/pkg/common/db/table/unrelation"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
@@ -48,7 +48,7 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.
|
||||
superGroupMemberMap := utils.SliceToMapAny(superGroupMembers, func(e *unrelation.SuperGroupModel) (string, []string) {
|
||||
return e.GroupID, e.MemberIDs
|
||||
})
|
||||
resp.Groups = utils.Slice(joinSuperGroup.GroupIDs, func(groupID string) *sdk_ws.GroupInfo {
|
||||
resp.Groups = utils.Slice(joinSuperGroup.GroupIDs, func(groupID string) *sdkws.GroupInfo {
|
||||
return DbToPbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, uint32(len(superGroupMemberMap)))
|
||||
})
|
||||
return resp, nil
|
||||
@@ -77,7 +77,7 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *sdk_ws.GroupInfo {
|
||||
resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *sdkws.GroupInfo {
|
||||
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(len(superGroupMemberMap[e.GroupID])))
|
||||
})
|
||||
return resp, nil
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
common "Open_IM/pkg/proto/sdk_ws"
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
@@ -116,10 +116,10 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
|
||||
}
|
||||
return &rResp, nil
|
||||
}
|
||||
setValue := make(map[string]*server_api_params.KeyValue)
|
||||
setValue := make(map[string]*sdkws.KeyValue)
|
||||
for k, v := range req.ReactionExtensionList {
|
||||
|
||||
temp := new(server_api_params.KeyValue)
|
||||
temp := new(sdkws.KeyValue)
|
||||
if vv, ok := mongoValue.ReactionExtensionList[k]; ok {
|
||||
utils.CopyStructFields(temp, &vv)
|
||||
if v.LatestUpdateTime != vv.LatestUpdateTime {
|
||||
@@ -168,7 +168,7 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
|
||||
setKeyResultInfo(&rResp, 200, err.Error(), req.ClientMsgID, k, v)
|
||||
continue
|
||||
}
|
||||
temp := new(server_api_params.KeyValue)
|
||||
temp := new(sdkws.KeyValue)
|
||||
utils.JsonStringToStruct(redisValue, temp)
|
||||
if v.LatestUpdateTime != temp.LatestUpdateTime {
|
||||
setKeyResultInfo(&rResp, 300, "message have update", req.ClientMsgID, k, temp)
|
||||
@@ -198,7 +198,7 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
|
||||
return &rResp, nil
|
||||
|
||||
}
|
||||
func setKeyResultInfo(r *msg.SetMessageReactionExtensionsResp, errCode int32, errMsg, clientMsgID, typeKey string, keyValue *server_api_params.KeyValue) {
|
||||
func setKeyResultInfo(r *msg.SetMessageReactionExtensionsResp, errCode int32, errMsg, clientMsgID, typeKey string, keyValue *sdkws.KeyValue) {
|
||||
temp := new(msg.KeyValueResp)
|
||||
temp.KeyValue = keyValue
|
||||
temp.ErrCode = errCode
|
||||
@@ -206,7 +206,7 @@ func setKeyResultInfo(r *msg.SetMessageReactionExtensionsResp, errCode int32, er
|
||||
r.Result = append(r.Result, temp)
|
||||
_ = db.DB.UnLockMessageTypeKey(clientMsgID, typeKey)
|
||||
}
|
||||
func setDeleteKeyResultInfo(r *msg.DeleteMessageListReactionExtensionsResp, errCode int32, errMsg, clientMsgID, typeKey string, keyValue *server_api_params.KeyValue) {
|
||||
func setDeleteKeyResultInfo(r *msg.DeleteMessageListReactionExtensionsResp, errCode int32, errMsg, clientMsgID, typeKey string, keyValue *sdkws.KeyValue) {
|
||||
temp := new(msg.KeyValueResp)
|
||||
temp.KeyValue = keyValue
|
||||
temp.ErrCode = errCode
|
||||
@@ -236,10 +236,10 @@ func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *m
|
||||
rResp.SingleMessageResult = append(rResp.SingleMessageResult, &oneMessage)
|
||||
continue
|
||||
}
|
||||
keyMap := make(map[string]*server_api_params.KeyValue)
|
||||
keyMap := make(map[string]*sdkws.KeyValue)
|
||||
|
||||
for k, v := range redisValue {
|
||||
temp := new(server_api_params.KeyValue)
|
||||
temp := new(sdkws.KeyValue)
|
||||
utils.JsonStringToStruct(v, temp)
|
||||
keyMap[k] = temp
|
||||
}
|
||||
@@ -253,10 +253,10 @@ func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *m
|
||||
rResp.SingleMessageResult = append(rResp.SingleMessageResult, &oneMessage)
|
||||
continue
|
||||
}
|
||||
keyMap := make(map[string]*server_api_params.KeyValue)
|
||||
keyMap := make(map[string]*sdkws.KeyValue)
|
||||
|
||||
for k, v := range mongoValue.ReactionExtensionList {
|
||||
temp := new(server_api_params.KeyValue)
|
||||
temp := new(sdkws.KeyValue)
|
||||
temp.TypeKey = v.TypeKey
|
||||
temp.Value = v.Value
|
||||
temp.LatestUpdateTime = v.LatestUpdateTime
|
||||
@@ -300,7 +300,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms
|
||||
}
|
||||
for _, v := range callbackResp.ResultReactionExtensionList {
|
||||
if v.ErrCode != 0 {
|
||||
func(req *[]*server_api_params.KeyValue, typeKey string) {
|
||||
func(req *[]*sdkws.KeyValue, typeKey string) {
|
||||
for i := 0; i < len(*req); i++ {
|
||||
if (*req)[i].TypeKey == typeKey {
|
||||
*req = append((*req)[:i], (*req)[i+1:]...)
|
||||
@@ -338,7 +338,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms
|
||||
setDeleteKeyResultInfo(&rResp, 200, err.Error(), req.ClientMsgID, v.TypeKey, v)
|
||||
continue
|
||||
}
|
||||
temp := new(server_api_params.KeyValue)
|
||||
temp := new(sdkws.KeyValue)
|
||||
utils.JsonStringToStruct(redisValue, temp)
|
||||
if v.LatestUpdateTime != temp.LatestUpdateTime {
|
||||
setDeleteKeyResultInfo(&rResp, 300, "message have update", req.ClientMsgID, v.TypeKey, temp)
|
||||
@@ -379,10 +379,10 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms
|
||||
}
|
||||
return &rResp, nil
|
||||
}
|
||||
setValue := make(map[string]*server_api_params.KeyValue)
|
||||
setValue := make(map[string]*sdkws.KeyValue)
|
||||
for _, v := range req.ReactionExtensionList {
|
||||
|
||||
temp := new(server_api_params.KeyValue)
|
||||
temp := new(sdkws.KeyValue)
|
||||
if vv, ok := mongoValue.ReactionExtensionList[v.TypeKey]; ok {
|
||||
utils.CopyStructFields(temp, &vv)
|
||||
if v.LatestUpdateTime != vv.LatestUpdateTime {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
utils2 "Open_IM/pkg/common/utils"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
|
||||
@@ -3,7 +3,7 @@ package msg
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
utils2 "Open_IM/pkg/common/utils"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func OrganizationNotificationToAll(opUserID string, operationID string) {
|
||||
err, userIDList := imdb.GetAllOrganizationUserID()
|
||||
if err != nil {
|
||||
log.Error(operationID, "GetAllOrganizationUserID failed ", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
tips := open_im_sdk.OrganizationChangedTips{OpUser: &open_im_sdk.UserInfo{}}
|
||||
|
||||
user, err := imdb.GetUserByUserID(opUserID)
|
||||
if err != nil {
|
||||
log.NewError(operationID, "GetUserByUserID failed ", err.Error(), opUserID)
|
||||
return
|
||||
}
|
||||
utils2.UserDBCopyOpenIM(tips.OpUser, user)
|
||||
|
||||
for _, v := range userIDList {
|
||||
log.Debug(operationID, "OrganizationNotification", opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
|
||||
OrganizationNotification(config.Config.Manager.AppManagerUid[0], v, constant.OrganizationChangedNotification, &tips, operationID)
|
||||
}
|
||||
}
|
||||
|
||||
func OrganizationNotification(opUserID string, recvUserID string, contentType int32, m proto.Message, operationID string) {
|
||||
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, opUserID)
|
||||
var err error
|
||||
var tips open_im_sdk.TipsComm
|
||||
tips.Detail, err = proto.Marshal(m)
|
||||
if err != nil {
|
||||
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
||||
return
|
||||
}
|
||||
|
||||
marshaler := jsonpb.Marshaler{
|
||||
OrigName: true,
|
||||
EnumsAsInts: false,
|
||||
EmitDefaults: false,
|
||||
}
|
||||
|
||||
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||
|
||||
switch contentType {
|
||||
case constant.OrganizationChangedNotification:
|
||||
tips.DefaultTips = "OrganizationChangedNotification"
|
||||
|
||||
default:
|
||||
log.Error(operationID, "contentType failed ", contentType)
|
||||
return
|
||||
}
|
||||
|
||||
var n NotificationMsg
|
||||
n.SendID = opUserID
|
||||
n.RecvID = recvUserID
|
||||
n.ContentType = contentType
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.SysMsgType
|
||||
n.OperationID = operationID
|
||||
n.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
||||
return
|
||||
}
|
||||
Notification(&n)
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -293,7 +293,7 @@ func (rpc *rpcChat) messageVerification(ctx context.Context, data *pbChat.SendMs
|
||||
}
|
||||
|
||||
}
|
||||
func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
||||
func (rpc *rpcChat) encapsulateMsgData(msg *sdkws.MsgData) {
|
||||
msg.ServerMsgID = GetMsgID(msg.SendID)
|
||||
msg.SendTime = utils.GetCurrentTimestampByMill()
|
||||
switch msg.ContentType {
|
||||
@@ -449,8 +449,8 @@ func (rpc *rpcChat) SendMsg(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat
|
||||
var addUidList []string
|
||||
switch pb.MsgData.ContentType {
|
||||
case constant.MemberKickedNotification:
|
||||
var tips sdk_ws.TipsComm
|
||||
var memberKickedTips sdk_ws.MemberKickedTips
|
||||
var tips sdkws.TipsComm
|
||||
var memberKickedTips sdkws.MemberKickedTips
|
||||
err := proto.Unmarshal(pb.MsgData.Content, &tips)
|
||||
if err != nil {
|
||||
log.Error(pb.OperationID, "Unmarshal err", err.Error())
|
||||
@@ -761,8 +761,8 @@ type NotificationMsg struct {
|
||||
|
||||
func Notification(n *NotificationMsg) {
|
||||
var req pbChat.SendMsgReq
|
||||
var msg sdk_ws.MsgData
|
||||
var offlineInfo sdk_ws.OfflinePushInfo
|
||||
var msg sdkws.MsgData
|
||||
var offlineInfo sdkws.OfflinePushInfo
|
||||
var title, desc, ex string
|
||||
var pushSwitch, unReadCount bool
|
||||
var reliabilityLevel int
|
||||
@@ -975,14 +975,6 @@ func Notification(n *NotificationMsg) {
|
||||
reliabilityLevel = config.Config.Notification.GroupMemberInfoSet.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupMemberInfoSet.Conversation.UnreadCount
|
||||
|
||||
case constant.OrganizationChangedNotification:
|
||||
pushSwitch = config.Config.Notification.OrganizationChanged.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.OrganizationChanged.OfflinePush.Title
|
||||
desc = config.Config.Notification.OrganizationChanged.OfflinePush.Desc
|
||||
ex = config.Config.Notification.OrganizationChanged.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.OrganizationChanged.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.OrganizationChanged.Conversation.UnreadCount
|
||||
|
||||
case constant.WorkMomentNotification:
|
||||
pushSwitch = config.Config.Notification.WorkMomentsNotification.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.WorkMomentsNotification.OfflinePush.Title
|
||||
@@ -1087,11 +1079,11 @@ func getOnlineAndOfflineUserIDList(memberList []string, m map[string][]string, o
|
||||
}
|
||||
|
||||
func valueCopy(pb *pbChat.SendMsgReq) *pbChat.SendMsgReq {
|
||||
offlinePushInfo := sdk_ws.OfflinePushInfo{}
|
||||
offlinePushInfo := sdkws.OfflinePushInfo{}
|
||||
if pb.MsgData.OfflinePushInfo != nil {
|
||||
offlinePushInfo = *pb.MsgData.OfflinePushInfo
|
||||
}
|
||||
msgData := sdk_ws.MsgData{}
|
||||
msgData := sdkws.MsgData{}
|
||||
msgData = *pb.MsgData
|
||||
msgData.OfflinePushInfo = &offlinePushInfo
|
||||
|
||||
@@ -1105,11 +1097,11 @@ func valueCopy(pb *pbChat.SendMsgReq) *pbChat.SendMsgReq {
|
||||
|
||||
func (rpc *rpcChat) sendMsgToGroup(ctx context.Context, list []string, pb pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) {
|
||||
// log.Debug(pb.OperationID, "split userID ", list)
|
||||
offlinePushInfo := sdk_ws.OfflinePushInfo{}
|
||||
offlinePushInfo := sdkws.OfflinePushInfo{}
|
||||
if pb.MsgData.OfflinePushInfo != nil {
|
||||
offlinePushInfo = *pb.MsgData.OfflinePushInfo
|
||||
}
|
||||
msgData := sdk_ws.MsgData{}
|
||||
msgData := sdkws.MsgData{}
|
||||
msgData = *pb.MsgData
|
||||
msgData.OfflinePushInfo = &offlinePushInfo
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package msg
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
//sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
//sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
//"github.com/golang/protobuf/jsonpb"
|
||||
//"github.com/golang/protobuf/proto"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbOffice "Open_IM/pkg/proto/office"
|
||||
sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
pbCache "Open_IM/pkg/proto/cache"
|
||||
pbOffice "Open_IM/pkg/proto/office"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
pbCommon "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/OpenIMSDK/getcdv3"
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -125,7 +125,7 @@ func (s *userServer) SetGroupMemberFaceURL(ctx context.Context, faceURL string,
|
||||
}
|
||||
|
||||
// 获取加入的群成员信息
|
||||
func (s *userServer) GetJoinedGroupMembers(ctx context.Context, userID string) (members []*server_api_params.GroupMemberFullInfo, err error) {
|
||||
func (s *userServer) GetJoinedGroupMembers(ctx context.Context, userID string) (members []*sdkws.GroupMemberFullInfo, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbUser.GetDesig
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) GetAllPageFriends(ctx context.Context, ownerUserID string) (resp []*server_api_params.FriendInfo, err error) {
|
||||
func (s *userServer) GetAllPageFriends(ctx context.Context, ownerUserID string) (resp []*sdkws.FriendInfo, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbUser.GetPagi
|
||||
// ok
|
||||
func (s *userServer) UserRegister(ctx context.Context, req *pbUser.UserRegisterReq) (resp *pbUser.UserRegisterResp, err error) {
|
||||
resp = &pbUser.UserRegisterResp{}
|
||||
if utils.DuplicateAny(req.Users, func(e *server_api_params.UserInfo) string { return e.UserID }) {
|
||||
if utils.DuplicateAny(req.Users, func(e *sdkws.UserInfo) string { return e.UserID }) {
|
||||
return nil, constant.ErrArgs.Wrap("userID repeated")
|
||||
}
|
||||
userIDs := make([]string, 0)
|
||||
|
||||
Reference in New Issue
Block a user