diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 510d8cf55..a3a2c2c40 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -47,11 +47,11 @@ func main() { //group related routing group groupRouterGroup := r.Group("/group") { - groupRouterGroup.POST("/create_group", group.CreateGroup) //1 - groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1 - groupRouterGroup.POST("join_group", group.JoinGroup) //1 - groupRouterGroup.POST("/quit_group", group.QuitGroup) //1 - groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) + groupRouterGroup.POST("/create_group", group.CreateGroup) //1 + groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1 + groupRouterGroup.POST("join_group", group.JoinGroup) //1 + groupRouterGroup.POST("/quit_group", group.QuitGroup) //1 + groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1 groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList) //1 groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 diff --git a/internal/api/group/group.go b/internal/api/group/group.go index c7297e083..7fe82b1fe 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -464,7 +464,7 @@ func TransferGroupOwner(c *gin.Context) { return } req := &rpc.TransferGroupOwnerReq{} - utils.CopyStructFields(req, params) + utils.CopyStructFields(req, ¶ms) var ok bool ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) if !ok { @@ -483,7 +483,8 @@ func TransferGroupOwner(c *gin.Context) { return } - resp := api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg} - c.JSON(http.StatusOK, resp) + resp := api.TransferGroupOwnerResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}} log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp) + c.JSON(http.StatusOK, resp) + } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index b42badca2..fe34a7735 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -595,17 +595,19 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe log.NewInfo(req.OperationID, "TransferGroupOwner ", req.String()) if req.OldOwnerUserID == req.NewOwnerUserID { - log.NewError(req.OperationID, "same owner ", req.String()) + log.NewError(req.OperationID, "same owner ", req.OldOwnerUserID, req.NewOwnerUserID) return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil } - groupMemberInfo := imdb.GroupMember{GroupID: req.GroupID, UserID: req.OldOwnerUserID, RoleLevel: 0} + groupMemberInfo := imdb.GroupMember{GroupID: req.GroupID, UserID: req.OldOwnerUserID, RoleLevel: constant.GroupOrdinaryUsers} err := imdb.UpdateGroupMemberInfo(groupMemberInfo) if err != nil { + log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo) return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } - groupMemberInfo = imdb.GroupMember{GroupID: req.GroupID, UserID: req.NewOwnerUserID, RoleLevel: 1} + groupMemberInfo = imdb.GroupMember{GroupID: req.GroupID, UserID: req.NewOwnerUserID, RoleLevel: constant.GroupOwner} err = imdb.UpdateGroupMemberInfo(groupMemberInfo) if err != nil { + log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo) return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } changedType := int32(1) << 4 diff --git a/pkg/base_info/group_api_struct.go b/pkg/base_info/group_api_struct.go index fd4c8206b..f4c8fa666 100644 --- a/pkg/base_info/group_api_struct.go +++ b/pkg/base_info/group_api_struct.go @@ -149,3 +149,6 @@ type TransferGroupOwnerReq struct { NewOwnerUserID string `json:"newOwnerUserID" binding:"required"` OperationID string `json:"operationID" binding:"required"` } +type TransferGroupOwnerResp struct { + CommResp +}