mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
189020298e
@ -58,6 +58,7 @@ func main() {
|
|||||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
||||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||||
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
|
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
|
||||||
|
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
||||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||||
|
1
go.mod
1
go.mod
@ -47,6 +47,7 @@ require (
|
|||||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
|
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
|
||||||
google.golang.org/grpc v1.40.0
|
google.golang.org/grpc v1.40.0
|
||||||
|
google.golang.org/protobuf v1.27.1 // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||||
|
@ -290,13 +290,13 @@ func GetRecvGroupApplicationList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetGroupApplicationListReq{}
|
req := &rpc.GetGroupApplicationListReq{}
|
||||||
utils.CopyStructFields(req, params)
|
utils.CopyStructFields(req, params)
|
||||||
var ok bool
|
//var ok bool
|
||||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||||
if !ok {
|
//if !ok {
|
||||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -314,6 +314,37 @@ func GetRecvGroupApplicationList(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserReqGroupApplicationList(c *gin.Context) {
|
||||||
|
var params api.GetUserReqGroupApplicationListReq
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.GetUserReqApplicationListReq{}
|
||||||
|
utils.CopyStructFields(req, params)
|
||||||
|
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||||
|
//if !ok {
|
||||||
|
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, RpcResp)
|
||||||
|
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupRequestList: RpcResp.GroupRequestList}
|
||||||
|
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||||
|
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
func GetGroupsInfo(c *gin.Context) {
|
func GetGroupsInfo(c *gin.Context) {
|
||||||
params := api.GetGroupInfoReq{}
|
params := api.GetGroupInfoReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
@ -638,3 +638,41 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
|
|||||||
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbGroup.GetUserReqApplicationListResp{}
|
||||||
|
groupRequests, err := imdb.GetUserReqGroupByUserID(req.UserID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserReqGroupByUserID failed ", err.Error())
|
||||||
|
resp.CommonResp = &pbGroup.CommonResp{
|
||||||
|
ErrCode: constant.ErrDB.ErrCode,
|
||||||
|
ErrMsg: constant.ErrDB.ErrMsg,
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, groupReq := range groupRequests {
|
||||||
|
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
|
group, err := imdb.GetGroupInfoByGroupID(groupReq.GroupID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupReq.GroupID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
user, err := imdb.GetUserByUserID(groupReq.UserID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "GetUserByUserID failed ", err.Error(), groupReq.UserID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cp.GroupRequestDBCopyOpenIM(&node, &groupReq)
|
||||||
|
cp.UserDBCopyOpenIMPublicUser(node.UserInfo, user)
|
||||||
|
cp.GroupDBCopyOpenIM(node.GroupInfo, group)
|
||||||
|
resp.GroupRequestList = append(resp.GroupRequestList, &node)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupRequests)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "output:", resp)
|
||||||
|
resp.CommonResp = &pbGroup.CommonResp{
|
||||||
|
ErrCode: 0,
|
||||||
|
ErrMsg: "",
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
@ -103,6 +103,16 @@ type GetGroupApplicationListResp struct {
|
|||||||
Data []map[string]interface{} `json:"data"`
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetUserReqGroupApplicationListReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
UserID string `json:"userID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserRespGroupApplicationResp struct {
|
||||||
|
CommResp
|
||||||
|
GroupRequestList []*open_im_sdk.GroupRequest `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
type GetGroupInfoReq struct {
|
type GetGroupInfoReq struct {
|
||||||
GroupIDList []string `json:"groupIDList" binding:"required"`
|
GroupIDList []string `json:"groupIDList" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
@ -225,6 +225,7 @@ func IsGroupOwnerAdmin(groupID, UserID string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//func SelectGroupList(groupID string) ([]string, error) {
|
//func SelectGroupList(groupID string) ([]string, error) {
|
||||||
// var groupUserID string
|
// var groupUserID string
|
||||||
|
@ -117,6 +117,18 @@ func GetGroupApplicationList(userID string) ([]db.GroupRequest, error) {
|
|||||||
return groupRequestList, nil
|
return groupRequestList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserReqGroupByUserID(userID string) ([]db.GroupRequest, error) {
|
||||||
|
var groupRequestList []db.GroupRequest
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dbConn.LogMode(true)
|
||||||
|
err = dbConn.Table("group_requests").Where("user_id=?", userID).Find(&groupRequestList).Error
|
||||||
|
return groupRequestList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.CommonResp, error) {
|
//func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.CommonResp, error) {
|
||||||
//
|
//
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,17 @@ message GetGroupApplicationListResp {
|
|||||||
repeated server_api_params.GroupRequest GroupRequestList = 3;
|
repeated server_api_params.GroupRequest GroupRequestList = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetUserReqApplicationListReq{
|
||||||
|
string UserID = 1;
|
||||||
|
string OpUserID = 2;
|
||||||
|
string OperationID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserReqApplicationListResp{
|
||||||
|
CommonResp CommonResp = 1;
|
||||||
|
repeated server_api_params.GroupRequest GroupRequestList = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
message TransferGroupOwnerReq {
|
message TransferGroupOwnerReq {
|
||||||
string GroupID = 1;
|
string GroupID = 1;
|
||||||
@ -204,6 +215,7 @@ service group{
|
|||||||
rpc getGroupsInfo(GetGroupsInfoReq) returns(GetGroupsInfoResp);
|
rpc getGroupsInfo(GetGroupsInfoReq) returns(GetGroupsInfoResp);
|
||||||
rpc setGroupInfo(SetGroupInfoReq) returns(SetGroupInfoResp);
|
rpc setGroupInfo(SetGroupInfoReq) returns(SetGroupInfoResp);
|
||||||
rpc getGroupApplicationList(GetGroupApplicationListReq) returns(GetGroupApplicationListResp);
|
rpc getGroupApplicationList(GetGroupApplicationListReq) returns(GetGroupApplicationListResp);
|
||||||
|
rpc getUserReqApplicationList(GetUserReqApplicationListReq) returns(GetUserReqApplicationListResp);
|
||||||
rpc transferGroupOwner(TransferGroupOwnerReq) returns(TransferGroupOwnerResp);
|
rpc transferGroupOwner(TransferGroupOwnerReq) returns(TransferGroupOwnerResp);
|
||||||
rpc groupApplicationResponse(GroupApplicationResponseReq) returns(GroupApplicationResponseResp);
|
rpc groupApplicationResponse(GroupApplicationResponseReq) returns(GroupApplicationResponseResp);
|
||||||
rpc getGroupMemberList(GetGroupMemberListReq) returns(GetGroupMemberListResp);
|
rpc getGroupMemberList(GetGroupMemberListReq) returns(GetGroupMemberListResp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user