|
|
@ -16,8 +16,8 @@ import (
|
|
|
|
"Open_IM/pkg/common/token_verify"
|
|
|
|
"Open_IM/pkg/common/token_verify"
|
|
|
|
"Open_IM/pkg/common/tracelog"
|
|
|
|
"Open_IM/pkg/common/tracelog"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/getcdv3"
|
|
|
|
|
|
|
|
|
|
|
|
"Open_IM/pkg/getcdv3"
|
|
|
|
|
|
|
|
pbConversation "Open_IM/pkg/proto/conversation"
|
|
|
|
pbConversation "Open_IM/pkg/proto/conversation"
|
|
|
|
pbGroup "Open_IM/pkg/proto/group"
|
|
|
|
pbGroup "Open_IM/pkg/proto/group"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
@ -42,6 +42,9 @@ type groupServer struct {
|
|
|
|
etcdSchema string
|
|
|
|
etcdSchema string
|
|
|
|
etcdAddr []string
|
|
|
|
etcdAddr []string
|
|
|
|
controller.GroupInterface
|
|
|
|
controller.GroupInterface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userRpc pbUser.UserClient
|
|
|
|
|
|
|
|
conversationRpc pbConversation.ConversationClient
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewGroupServer(port int) *groupServer {
|
|
|
|
func NewGroupServer(port int) *groupServer {
|
|
|
@ -52,12 +55,29 @@ func NewGroupServer(port int) *groupServer {
|
|
|
|
etcdSchema: config.Config.Etcd.EtcdSchema,
|
|
|
|
etcdSchema: config.Config.Etcd.EtcdSchema,
|
|
|
|
etcdAddr: config.Config.Etcd.EtcdAddr,
|
|
|
|
etcdAddr: config.Config.Etcd.EtcdAddr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ttl := 10
|
|
|
|
|
|
|
|
etcdClient, err := getcdv3.NewEtcdConn(g.rpcRegisterName, strings.Join(g.etcdAddr, ","), config.Config.RpcRegisterIP, config.Config.Etcd.UserName, config.Config.Etcd.Password, port, ttl)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic("NewEtcdConn failed" + err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
err = etcdClient.RegisterEtcd("", g.rpcRegisterName)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic("NewEtcdConn failed" + err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
etcdClient.SetDefaultEtcdConfig(config.Config.RpcRegisterName.OpenImUserName, config.Config.RpcPort.OpenImUserPort)
|
|
|
|
|
|
|
|
conn := etcdClient.GetConn("", config.Config.RpcRegisterName.OpenImUserName)
|
|
|
|
|
|
|
|
g.userRpc = pbUser.NewUserClient(conn)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
etcdClient.SetDefaultEtcdConfig(config.Config.RpcRegisterName.OpenImConversationName, config.Config.RpcPort.OpenImConversationPort)
|
|
|
|
|
|
|
|
conn = etcdClient.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)
|
|
|
|
|
|
|
|
g.conversationRpc = pbConversation.NewConversationClient(conn)
|
|
|
|
|
|
|
|
|
|
|
|
//mysql init
|
|
|
|
//mysql init
|
|
|
|
var mysql relation.Mysql
|
|
|
|
var mysql relation.Mysql
|
|
|
|
var mongo unrelation.Mongo
|
|
|
|
var mongo unrelation.Mongo
|
|
|
|
var groupModel table.GroupModel
|
|
|
|
var groupModel table.GroupModel
|
|
|
|
var redis cache.RedisClient
|
|
|
|
var redis cache.RedisClient
|
|
|
|
err := mysql.InitConn().AutoMigrateModel(&groupModel)
|
|
|
|
err = mysql.InitConn().AutoMigrateModel(&groupModel)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic("db init err:" + err.Error())
|
|
|
|
panic("db init err:" + err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -870,19 +890,6 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if req.GroupInfoForSet.Notification != "" {
|
|
|
|
if req.GroupInfoForSet.Notification != "" {
|
|
|
|
//get group member user id
|
|
|
|
//get group member user id
|
|
|
|
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: tracelog.GetOperationID(ctx), GroupID: req.GroupInfoForSet.GroupID}
|
|
|
|
|
|
|
|
etcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
client := pbCache.NewCacheClient(etcdConn)
|
|
|
|
|
|
|
|
cacheResp, err := client.GetGroupMemberIDListFromCache(ctx, getGroupMemberIDListFromCacheReq)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = constant.CommonResp2Err(cacheResp.CommonResp); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var conversationReq pbConversation.ModifyConversationFieldReq
|
|
|
|
var conversationReq pbConversation.ModifyConversationFieldReq
|
|
|
|
conversation := pbConversation.Conversation{
|
|
|
|
conversation := pbConversation.Conversation{
|
|
|
|
OwnerUserID: tracelog.GetOpUserID(ctx),
|
|
|
|
OwnerUserID: tracelog.GetOpUserID(ctx),
|
|
|
@ -895,12 +902,8 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|
|
|
conversationReq.FieldType = constant.FieldGroupAtType
|
|
|
|
conversationReq.FieldType = constant.FieldGroupAtType
|
|
|
|
conversation.GroupAtType = constant.GroupNotification
|
|
|
|
conversation.GroupAtType = constant.GroupNotification
|
|
|
|
conversationReq.UserIDList = cacheResp.UserIDList
|
|
|
|
conversationReq.UserIDList = cacheResp.UserIDList
|
|
|
|
nEtcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
_, err := s.conversationRpc.ModifyConversationField(ctx, &conversationReq)
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
|
|
|
|
|
|
|
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
|
|
|
|
|
|
|
tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
|
|
|
|
tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resp, nil
|
|
|
|
return resp, nil
|
|
|
|