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,7 +49,7 @@ func main() {
|
||||
{
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //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("/group_application_response", group.ApplicationGroupResponse)
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
|
||||
|
@ -258,7 +258,7 @@ func CreateGroup(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//my application 我发出去的
|
||||
// 群主或管理员收到的
|
||||
func GetGroupApplicationList(c *gin.Context) {
|
||||
params := api.GetGroupApplicationListReq{}
|
||||
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)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, Data: reply.GroupRequestList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||
if len(resp.GroupRequestList) == 0 {
|
||||
resp.GroupRequestList = []*open_im_sdk.GroupRequest{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetGroupsInfo(c *gin.Context) {
|
||||
@ -299,7 +302,7 @@ func GetGroupsInfo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupsInfoReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
if !ok {
|
||||
@ -318,9 +321,12 @@ func GetGroupsInfo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
||||
if len(resp.GroupInfoList) == 0 {
|
||||
resp.GroupInfoList = []*open_im_sdk.GroupInfo{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//process application
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
cp "Open_IM/pkg/common/utils"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
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) {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
log.NewDebug(req.OperationID, "GetGroupApplicationList reply ", reply)
|
||||
resp := pbGroup.GetGroupApplicationListResp{}
|
||||
for _, v := range reply {
|
||||
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)
|
||||
return &resp, nil
|
||||
@ -415,8 +419,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
continue
|
||||
}
|
||||
var groupInfo open_im_sdk.GroupInfo
|
||||
utils.CopyStructFields(&groupInfo, groupInfoFromMysql)
|
||||
groupInfo.CreateTime = groupInfoFromMysql.CreateTime.Unix()
|
||||
cp.GroupDBCopyOpenIM(&groupInfo, groupInfoFromMysql)
|
||||
groupsInfoList = append(groupsInfoList, &groupInfo)
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ type CreateGroupResp struct {
|
||||
|
||||
type GetGroupApplicationListReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
FromUserID string `json:"fromUserID" binding:"required"` //my application
|
||||
FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
|
||||
}
|
||||
type GetGroupApplicationListResp struct {
|
||||
CommResp
|
||||
Data []*open_im_sdk.GroupRequest `json:"data"`
|
||||
GroupRequestList []*open_im_sdk.GroupRequest `json:"data"`
|
||||
}
|
||||
|
||||
type GetGroupInfoReq struct {
|
||||
@ -104,7 +104,7 @@ type GetGroupInfoReq struct {
|
||||
}
|
||||
type GetGroupInfoResp struct {
|
||||
CommResp
|
||||
Data []open_im_sdk.GroupInfo `json:"data"`
|
||||
GroupInfoList []*open_im_sdk.GroupInfo `json:"data"`
|
||||
}
|
||||
|
||||
type ApplicationGroupResponseReq struct {
|
||||
|
@ -104,9 +104,12 @@ func GetGroupApplicationList(userID string) ([]GroupRequest, error) {
|
||||
if v.RoleLevel > constant.GroupOrdinaryUsers {
|
||||
list, err := GetGroupRequestByGroupID(v.GroupID)
|
||||
if err != nil {
|
||||
// fmt.Println("111 GetGroupRequestByGroupID failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
// fmt.Println("222 GetGroupRequestByGroupID ok ", list)
|
||||
groupRequestList = append(groupRequestList, list...)
|
||||
// fmt.Println("333 GetGroupRequestByGroupID ok ", groupRequestList)
|
||||
}
|
||||
}
|
||||
return groupRequestList, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user