mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-21 09:19:01 +08:00
cms
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
groupRpc "Open_IM/pkg/proto/group"
|
||||
|
||||
organizationRpc "Open_IM/pkg/proto/organization"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ChImportFriend chan *pbFriend.ImportFriendReq
|
||||
|
||||
func init() {
|
||||
ChImportFriend = make(chan *pbFriend.ImportFriendReq, 1000)
|
||||
}
|
||||
|
||||
func ImportFriendRoutine() {
|
||||
for {
|
||||
req := <-ChImportFriend
|
||||
go func() {
|
||||
friendUserIDList, err := imdb.GetRegisterAddFriendList(0, 0)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req, err.Error())
|
||||
return
|
||||
}
|
||||
if len(friendUserIDList) == 0 {
|
||||
return
|
||||
}
|
||||
req.FriendUserIDList = friendUserIDList
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
rpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
|
||||
return
|
||||
}
|
||||
if rpcResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", rpcResp)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
@@ -132,6 +133,17 @@ func SetPassword(c *gin.Context) {
|
||||
log.NewWarn(params.OperationID, utils.GetSelfFuncName(), "to ch timeOut")
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
||||
OperationID: params.OperationID,
|
||||
FromUserID: userID,
|
||||
OpUserID: userID,
|
||||
}:
|
||||
case <-time.After(time.Second * 2):
|
||||
log.NewWarn(params.OperationID, utils.GetSelfFuncName(), "to ChImportFriend timeOut")
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user