mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 03:25:59 +08:00
Merge remote-tracking branch 'origin/superGroup' into superGroup
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/ptypes/wrappers"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -806,6 +807,56 @@ func SetGroupMemberNickname(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetGroupMemberIDListFromCache(c *gin.Context) {
|
||||
func SetGroupMemberInfo(c *gin.Context) {
|
||||
var (
|
||||
req api.SetGroupMemberInfoReq
|
||||
resp api.SetGroupMemberInfoResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
var opUserID string
|
||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb := &rpc.SetGroupMemberInfoReq{
|
||||
GroupID: req.GroupID,
|
||||
UserID: req.UserID,
|
||||
OperationID: req.OperationID,
|
||||
OpUserID: opUserID,
|
||||
}
|
||||
if req.Nickname != nil {
|
||||
reqPb.Nickname = &wrappers.StringValue{Value: *req.Nickname}
|
||||
}
|
||||
if req.FaceURL != nil {
|
||||
reqPb.FaceURL = &wrappers.StringValue{Value: *req.FaceURL}
|
||||
}
|
||||
if req.Ex != nil {
|
||||
reqPb.Ex = &wrappers.StringValue{Value: *req.Ex}
|
||||
}
|
||||
if req.RoleLevel != nil {
|
||||
reqPb.RoleLevel = &wrappers.Int32Value{Value: *req.RoleLevel}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
respPb, err := client.SetGroupMemberInfo(context.Background(), reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", resp)
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetRTCInvitationInfo(c *gin.Context) {
|
||||
var (
|
||||
req api.GetRTCInvitationInfoReq
|
||||
resp api.GetRTCInvitationInfoResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
var err error
|
||||
invitationInfo, err := db.DB.GetSignalInfoFromCacheByClientMsgID(req.ClientMsgID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetRTCInvitationInfoStartApp(c *gin.Context) {
|
||||
var (
|
||||
req api.GetRTCInvitationInfoStartAppReq
|
||||
resp api.GetRTCInvitationInfoStartAppResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
invitationInfo, err := db.DB.GetAvailableSignalInvitationInfo(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": err.Error(), "data": struct{}{}})
|
||||
return
|
||||
}
|
||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
@@ -161,6 +161,7 @@ func onboardingProcessNotification(operationID, userID, groupID string) {
|
||||
}()
|
||||
var tips commonPb.TipsComm
|
||||
tips.DefaultTips = config.Config.Notification.JoinDepartmentNotification.DefaultTips.Tips
|
||||
tips.JsonDetail = ""
|
||||
content, err := proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), "proto marshal failed")
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
http2 "net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func callbackUserOnline(operationID, userID string, platformID int, token string) cbApi.CommonCallbackResp {
|
||||
@@ -21,7 +22,9 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
|
||||
UserID: userID,
|
||||
PlatformID: int32(platformID),
|
||||
Platform: constant.PlatformIDToName(platformID),
|
||||
}}
|
||||
},
|
||||
Seq: time.Now().Nanosecond() / 1e6,
|
||||
}
|
||||
callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
@@ -35,13 +38,16 @@ func callbackUserOffline(operationID, userID string, platformID int) cbApi.Commo
|
||||
if !config.Config.Callback.CallbackUserOffline.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
callbackOfflineReq := cbApi.CallbackUserOfflineReq{UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
|
||||
CallbackCommand: constant.CallbackUserOfflineCommand,
|
||||
OperationID: operationID,
|
||||
UserID: userID,
|
||||
PlatformID: int32(platformID),
|
||||
Platform: constant.PlatformIDToName(platformID),
|
||||
}}
|
||||
callbackOfflineReq := cbApi.CallbackUserOfflineReq{
|
||||
UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
|
||||
CallbackCommand: constant.CallbackUserOfflineCommand,
|
||||
OperationID: operationID,
|
||||
UserID: userID,
|
||||
PlatformID: int32(platformID),
|
||||
Platform: constant.PlatformIDToName(platformID),
|
||||
},
|
||||
Seq: time.Now().Nanosecond() / 1e6,
|
||||
}
|
||||
callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
|
||||
@@ -3,6 +3,7 @@ package gate
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
@@ -248,7 +249,13 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||
ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
|
||||
// save invitation info for offline push
|
||||
if err := db.DB.NewCacheSignalInfo(pbData.MsgData); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), m, &signalResp)
|
||||
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
|
||||
} else {
|
||||
ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package getui
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
@@ -98,7 +99,7 @@ func newGetuiClient() *Getui {
|
||||
return &Getui{}
|
||||
}
|
||||
|
||||
func (g *Getui) Push(userIDList []string, alert, detailContent, operationID string) (resp string, err error) {
|
||||
func (g *Getui) Push(userIDList []string, alert, detailContent, operationID string, opts push.PushOpts) (resp string, err error) {
|
||||
token, err := db.DB.GetGetuiToken()
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "token:", token)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package push
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push"
|
||||
"Open_IM/internal/push/jpush/common"
|
||||
"Open_IM/internal/push/jpush/requestBody"
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -32,12 +33,20 @@ func (j *JPush) SetAlias(cid, alias string) (resp string, err error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (j *JPush) Push(accounts []string, alert, detailContent, operationID string) (string, error) {
|
||||
func (j *JPush) Push(accounts []string, alert, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
||||
|
||||
var pf requestBody.Platform
|
||||
pf.SetAll()
|
||||
var au requestBody.Audience
|
||||
au.SetAlias(accounts)
|
||||
var no requestBody.Notification
|
||||
|
||||
var extras requestBody.Extras
|
||||
if opts.Signal.ClientMsgID != "" {
|
||||
extras.ClientMsgID = opts.Signal.ClientMsgID
|
||||
}
|
||||
no.IOSEnableMutableContent()
|
||||
no.SetExtras(extras)
|
||||
no.SetAlert(alert)
|
||||
var me requestBody.Message
|
||||
me.SetMsgContent(detailContent)
|
||||
|
||||
@@ -15,11 +15,18 @@ type Android struct {
|
||||
Intent struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
} `json:"intent,omitempty"`
|
||||
Extras Extras `json:"extras"`
|
||||
}
|
||||
type Ios struct {
|
||||
Alert string `json:"alert,omitempty"`
|
||||
Sound string `json:"sound,omitempty"`
|
||||
Badge string `json:"badge,omitempty"`
|
||||
Alert string `json:"alert,omitempty"`
|
||||
Sound string `json:"sound,omitempty"`
|
||||
Badge string `json:"badge,omitempty"`
|
||||
Extras Extras `json:"extras"`
|
||||
MutableContent bool `json:"mutable-content"`
|
||||
}
|
||||
|
||||
type Extras struct {
|
||||
ClientMsgID string `json:"clientMsgID"`
|
||||
}
|
||||
|
||||
func (n *Notification) SetAlert(alert string) {
|
||||
@@ -29,8 +36,17 @@ func (n *Notification) SetAlert(alert string) {
|
||||
n.IOS.Alert = alert
|
||||
n.IOS.Sound = "default"
|
||||
n.IOS.Badge = "+1"
|
||||
|
||||
}
|
||||
|
||||
func (n *Notification) SetExtras(extras Extras) {
|
||||
n.IOS.Extras = extras
|
||||
n.Android.Extras = extras
|
||||
}
|
||||
|
||||
func (n *Notification) SetAndroidIntent() {
|
||||
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
|
||||
}
|
||||
|
||||
func (n *Notification) IOSEnableMutableContent() {
|
||||
n.IOS.MutableContent = true
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
http2 "net/http"
|
||||
)
|
||||
|
||||
func callbackOfflinePush(operationID, userID string, info *commonPb.OfflinePushInfo, platformID int32) cbApi.CommonCallbackResp {
|
||||
func callbackOfflinePush(operationID, userID string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
||||
return callbackResp
|
||||
@@ -19,10 +19,16 @@ func callbackOfflinePush(operationID, userID string, info *commonPb.OfflinePushI
|
||||
CallbackCommand: constant.CallbackOfflinePushCommand,
|
||||
OperationID: operationID,
|
||||
UserID: userID,
|
||||
PlatformID: platformID,
|
||||
Platform: constant.PlatformIDToName(int(platformID)),
|
||||
PlatformID: msg.SenderPlatformID,
|
||||
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||
},
|
||||
OfflinePushInfo: info,
|
||||
OfflinePushInfo: msg.OfflinePushInfo,
|
||||
SendID: msg.SendID,
|
||||
GroupID: msg.GroupID,
|
||||
ContentType: msg.ContentType,
|
||||
SessionType: msg.SessionType,
|
||||
AtUserIDList: msg.AtUserIDList,
|
||||
Content: string(msg.Content),
|
||||
}
|
||||
callbackOfflinePushResp := &cbApi.CallbackOfflinePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflinePushReq, callbackOfflinePushResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
||||
|
||||
@@ -7,16 +7,18 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
jpush "Open_IM/internal/push/jpush"
|
||||
"Open_IM/internal/push"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc"
|
||||
"strings"
|
||||
)
|
||||
@@ -99,11 +101,15 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
} else {
|
||||
content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||
}
|
||||
case constant.SignalingNotification:
|
||||
content = constant.ContentType2PushContent[constant.SignalMsg]
|
||||
default:
|
||||
content = constant.ContentType2PushContent[constant.Common]
|
||||
|
||||
}
|
||||
}
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList[0], pushMsg.MsgData.OfflinePushInfo, constant.AndroidPlatformID)
|
||||
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList[0], pushMsg.MsgData)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||
@@ -113,9 +119,14 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
return
|
||||
}
|
||||
if offlinePusher == nil {
|
||||
offlinePusher = jpush.JPushClient
|
||||
return
|
||||
}
|
||||
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID)
|
||||
opts, err := GetOfflinePushOpts(pushMsg)
|
||||
if err != nil {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
|
||||
}
|
||||
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, content, jsonCustomContent, "opts:", opts)
|
||||
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
|
||||
if err != nil {
|
||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||
} else {
|
||||
@@ -225,6 +236,23 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
//}
|
||||
}
|
||||
|
||||
func GetOfflinePushOpts(pushMsg *pbPush.PushMsgReq) (opts push.PushOpts, err error) {
|
||||
if pushMsg.MsgData.ContentType < constant.SignalingNotificationEnd && pushMsg.MsgData.ContentType > constant.SignalingNotificationBegin {
|
||||
req := &pbRtc.SignalReq{}
|
||||
if err := proto.Unmarshal(pushMsg.MsgData.Content, req); err != nil {
|
||||
return opts, utils.Wrap(err, "")
|
||||
}
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "SignalReq: ", req.String())
|
||||
switch req.Payload.(type) {
|
||||
case *pbRtc.SignalReq_Invite, *pbRtc.SignalReq_InviteInGroup:
|
||||
opts.Signal.ClientMsgID = pushMsg.MsgData.ClientMsgID
|
||||
log.NewDebug(pushMsg.OperationID, opts)
|
||||
}
|
||||
|
||||
}
|
||||
return opts, nil
|
||||
}
|
||||
|
||||
//func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {
|
||||
// m.MsgID = rpcChat.GetMsgID(m.SendID)
|
||||
// m.ClientMsgID = m.MsgID
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package push
|
||||
|
||||
type OfflinePusher interface {
|
||||
Push(userIDList []string, alert, detailContent, operationID string) (resp string, err error)
|
||||
Push(userIDList []string, alert, detailContent, operationID string, opts PushOpts) (resp string, err error)
|
||||
}
|
||||
|
||||
type PushOpts struct {
|
||||
Signal Signal
|
||||
}
|
||||
|
||||
type Signal struct {
|
||||
ClientMsgID string
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@ import (
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type adminCMSServer struct {
|
||||
@@ -62,6 +63,7 @@ func (s *adminCMSServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
|
||||
@@ -141,7 +141,7 @@ func (rpc *rpcAuth) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError(operationID, "RegisterEtcd failed ", err.Error(),
|
||||
|
||||
Vendored
+3
-2
@@ -11,11 +11,12 @@ import (
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type cacheServer struct {
|
||||
@@ -71,7 +72,7 @@ func (s *cacheServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
|
||||
@@ -164,6 +164,7 @@ func (rpc *rpcConversation) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error(),
|
||||
|
||||
@@ -15,11 +15,12 @@ import (
|
||||
sdkws "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type friendServer struct {
|
||||
@@ -69,7 +70,7 @@ func (s *friendServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
cp "Open_IM/pkg/common/utils"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbCache "Open_IM/pkg/proto/cache"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
@@ -71,6 +72,7 @@ func (s *groupServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("", "RegisterEtcd failed ", err.Error())
|
||||
@@ -934,6 +936,42 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
if changedType != 0 {
|
||||
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfo.GroupID, groupName, notification, introduction, faceURL)
|
||||
}
|
||||
if req.GroupInfo.Notification != "" {
|
||||
//get group member user id
|
||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: req.OperationID, GroupID: req.GroupInfo.GroupID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||
client := pbCache.NewCacheClient(etcdConn)
|
||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
||||
}
|
||||
if cacheResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
||||
}
|
||||
var conversationReq pbConversation.ModifyConversationFieldReq
|
||||
|
||||
conversation := pbConversation.Conversation{
|
||||
OwnerUserID: req.OpUserID,
|
||||
ConversationID: utils.GetConversationIDBySessionType(req.GroupInfo.GroupID, constant.GroupChatType),
|
||||
ConversationType: constant.GroupChatType,
|
||||
GroupID: req.GroupInfo.GroupID,
|
||||
}
|
||||
conversationReq.Conversation = &conversation
|
||||
conversationReq.OperationID = req.OperationID
|
||||
conversationReq.FieldType = constant.FieldGroupAtType
|
||||
conversation.GroupAtType = constant.GroupNotification
|
||||
conversationReq.UserIDList = cacheResp.UserIDList
|
||||
nEtcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
|
||||
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
||||
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
||||
if err != nil {
|
||||
log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error())
|
||||
} else if conversationReply.CommonResp.ErrCode != 0 {
|
||||
log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String())
|
||||
}
|
||||
}
|
||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
||||
}
|
||||
|
||||
@@ -1582,3 +1620,35 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (resp *pbGroup.SetGroupMemberInfoResp, err error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp = &pbGroup.SetGroupMemberInfoResp{CommonResp: &pbGroup.CommonResp{}}
|
||||
groupMember := db.GroupMember{
|
||||
GroupID: req.GroupID,
|
||||
UserID: req.UserID,
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.RoleLevel != nil {
|
||||
m["role_level"] = req.RoleLevel.Value
|
||||
}
|
||||
if req.FaceURL != nil {
|
||||
m["user_group_face_url"] = req.FaceURL.Value
|
||||
}
|
||||
if req.Nickname != nil {
|
||||
m["nickname"] = req.Nickname.Value
|
||||
}
|
||||
if req.Ex != nil {
|
||||
m["ex"] = req.Ex.Value
|
||||
}
|
||||
err = imdb.UpdateGroupMemberInfoByMap(groupMember, m)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetGroupMemberInfo failed", err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ func (s *messageCMSServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
|
||||
@@ -231,7 +231,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0)
|
||||
}
|
||||
memberUserIDList := cacheResp.UserIDList
|
||||
log.Debug(pb.OperationID, "GetGroupAllMember userID list", cacheResp.UserIDList)
|
||||
log.Debug(pb.OperationID, "GetGroupAllMember userID list", cacheResp.UserIDList, "len: ", len(cacheResp.UserIDList))
|
||||
var addUidList []string
|
||||
switch pb.MsgData.ContentType {
|
||||
case constant.MemberKickedNotification:
|
||||
@@ -861,6 +861,10 @@ func (rpc *rpcChat) sendMsgToGroupOptimization(list []string, groupPB *pbChat.Se
|
||||
groupPB.MsgData.RecvID = v
|
||||
isSend := modifyMessageByUserMessageReceiveOpt(v, groupPB.MsgData.GroupID, constant.GroupChatType, groupPB)
|
||||
if isSend {
|
||||
if v == "" || groupPB.MsgData.SendID == "" {
|
||||
log.Error(msgToMQGroup.OperationID, "sendMsgToGroupOptimization userID nil ", msgToMQGroup.String())
|
||||
continue
|
||||
}
|
||||
err := rpc.sendMsgToKafka(&msgToMQGroup, v, status)
|
||||
if err != nil {
|
||||
log.NewError(msgToMQGroup.OperationID, "kafka send msg err:UserId", v, msgToMQGroup.String())
|
||||
|
||||
@@ -14,13 +14,14 @@ import (
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type officeServer struct {
|
||||
@@ -77,7 +78,7 @@ func (s *officeServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
|
||||
@@ -9,17 +9,18 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/auth"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
groupRpc "Open_IM/pkg/proto/group"
|
||||
rpc "Open_IM/pkg/proto/organization"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type organizationServer struct {
|
||||
@@ -67,6 +68,7 @@ func (s *organizationServer) Run() {
|
||||
log.Error("", "GetLocalIP failed ", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("", "RegisterEtcd failed ", err.Error())
|
||||
@@ -152,7 +154,6 @@ func (s *organizationServer) UpdateDepartment(ctx context.Context, req *rpc.Upda
|
||||
|
||||
department := db.Department{}
|
||||
utils.CopyStructFields(&department, req.DepartmentInfo)
|
||||
|
||||
log.Debug(req.OperationID, "dst ", department, "src ", req.DepartmentInfo)
|
||||
if err := imdb.UpdateDepartment(&department, nil); err != nil {
|
||||
errMsg := req.OperationID + " " + "UpdateDepartment failed " + err.Error()
|
||||
@@ -341,6 +342,7 @@ func (s *organizationServer) GetDepartmentParentIDList(_ context.Context, req *r
|
||||
resp = &rpc.GetDepartmentParentIDListResp{}
|
||||
resp.ParentIDList, err = imdb.GetDepartmentParentIDList(req.DepartmentID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetDepartmentParentIDList failed", err.Error())
|
||||
resp.ErrMsg = constant.ErrDB.ErrMsg + ": " + err.Error()
|
||||
resp.ErrCode = constant.ErrDB.ErrCode
|
||||
return resp, nil
|
||||
|
||||
Reference in New Issue
Block a user