mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 03:26:57 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
e0c91f7fda
@ -49,8 +49,8 @@ func main() {
|
|||||||
{
|
{
|
||||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
||||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
||||||
groupRouterGroup.POST("join_group", group.JoinGroup)
|
groupRouterGroup.POST("join_group", group.JoinGroup) //1
|
||||||
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
||||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
|
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
|
||||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
|
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
|
||||||
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList)
|
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList)
|
||||||
|
@ -258,7 +258,7 @@ func CreateGroup(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//my application 我发出去的
|
// 群主或管理员收到的
|
||||||
func GetGroupApplicationList(c *gin.Context) {
|
func GetGroupApplicationList(c *gin.Context) {
|
||||||
params := api.GetGroupApplicationListReq{}
|
params := api.GetGroupApplicationListReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
@ -279,16 +279,19 @@ func GetGroupApplicationList(c *gin.Context) {
|
|||||||
|
|
||||||
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)
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
|
||||||
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, Data: reply.GroupRequestList}
|
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||||
c.JSON(http.StatusOK, resp)
|
if len(resp.GroupRequestList) == 0 {
|
||||||
|
resp.GroupRequestList = []*open_im_sdk.GroupRequest{}
|
||||||
|
}
|
||||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupsInfo(c *gin.Context) {
|
func GetGroupsInfo(c *gin.Context) {
|
||||||
@ -299,7 +302,7 @@ func GetGroupsInfo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
req := &rpc.GetGroupsInfoReq{}
|
req := &rpc.GetGroupsInfoReq{}
|
||||||
utils.CopyStructFields(req, params)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
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 {
|
||||||
@ -318,9 +321,12 @@ func GetGroupsInfo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}
|
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
||||||
c.JSON(http.StatusOK, resp)
|
if len(resp.GroupInfoList) == 0 {
|
||||||
|
resp.GroupInfoList = []*open_im_sdk.GroupInfo{}
|
||||||
|
}
|
||||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//process application
|
//process application
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
cp "Open_IM/pkg/common/utils"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
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"
|
||||||
@ -390,16 +391,19 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
|||||||
|
|
||||||
func (s *groupServer) GetGroupApplicationList(_ context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
|
func (s *groupServer) GetGroupApplicationList(_ context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||||
reply, err := im_mysql_model.GetGroupApplicationList(req.OpUserID)
|
reply, err := im_mysql_model.GetGroupApplicationList(req.FromUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.OpUserID)
|
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.FromUserID)
|
||||||
return &pbGroup.GetGroupApplicationListResp{ErrCode: 701, ErrMsg: "GetGroupApplicationList failed"}, nil
|
return &pbGroup.GetGroupApplicationListResp{ErrCode: 701, ErrMsg: "GetGroupApplicationList failed"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.NewDebug(req.OperationID, "GetGroupApplicationList reply ", reply)
|
||||||
resp := pbGroup.GetGroupApplicationListResp{}
|
resp := pbGroup.GetGroupApplicationListResp{}
|
||||||
for _, v := range reply {
|
for _, v := range reply {
|
||||||
var node open_im_sdk.GroupRequest
|
var node open_im_sdk.GroupRequest
|
||||||
utils.CopyStructFields(&node, v)
|
cp.GroupRequestDBCopyOpenIM(&node, &v)
|
||||||
|
log.NewDebug(req.OperationID, "node ", node, "v ", v)
|
||||||
|
resp.GroupRequestList = append(resp.GroupRequestList, &node)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo rpc return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupMembersInfo rpc return ", resp)
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
@ -415,8 +419,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var groupInfo open_im_sdk.GroupInfo
|
var groupInfo open_im_sdk.GroupInfo
|
||||||
utils.CopyStructFields(&groupInfo, groupInfoFromMysql)
|
cp.GroupDBCopyOpenIM(&groupInfo, groupInfoFromMysql)
|
||||||
groupInfo.CreateTime = groupInfoFromMysql.CreateTime.Unix()
|
|
||||||
groupsInfoList = append(groupsInfoList, &groupInfo)
|
groupsInfoList = append(groupsInfoList, &groupInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,11 +91,11 @@ type CreateGroupResp struct {
|
|||||||
|
|
||||||
type GetGroupApplicationListReq struct {
|
type GetGroupApplicationListReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"` //my application
|
FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
|
||||||
}
|
}
|
||||||
type GetGroupApplicationListResp struct {
|
type GetGroupApplicationListResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
Data []*open_im_sdk.GroupRequest `json:"data"`
|
GroupRequestList []*open_im_sdk.GroupRequest `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupInfoReq struct {
|
type GetGroupInfoReq struct {
|
||||||
@ -104,7 +104,7 @@ type GetGroupInfoReq struct {
|
|||||||
}
|
}
|
||||||
type GetGroupInfoResp struct {
|
type GetGroupInfoResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
Data []open_im_sdk.GroupInfo `json:"data"`
|
GroupInfoList []*open_im_sdk.GroupInfo `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplicationGroupResponseReq struct {
|
type ApplicationGroupResponseReq struct {
|
||||||
|
@ -104,9 +104,12 @@ func GetGroupApplicationList(userID string) ([]GroupRequest, error) {
|
|||||||
if v.RoleLevel > constant.GroupOrdinaryUsers {
|
if v.RoleLevel > constant.GroupOrdinaryUsers {
|
||||||
list, err := GetGroupRequestByGroupID(v.GroupID)
|
list, err := GetGroupRequestByGroupID(v.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// fmt.Println("111 GetGroupRequestByGroupID failed ", err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// fmt.Println("222 GetGroupRequestByGroupID ok ", list)
|
||||||
groupRequestList = append(groupRequestList, list...)
|
groupRequestList = append(groupRequestList, list...)
|
||||||
|
// fmt.Println("333 GetGroupRequestByGroupID ok ", groupRequestList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return groupRequestList, nil
|
return groupRequestList, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user