Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/232/head
wenxu12345 3 years ago
commit 450d8c21cf

@ -123,6 +123,7 @@ func main() {
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
managementGroup.POST("/account_check", manage.AccountCheck) //1
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
}
//Conversation
conversationGroup := r.Group("/conversation")

@ -98,7 +98,8 @@ credential: #腾讯cos发送图片、视频、文件时需要请自行申
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK中 object_storage参数为minio
bucket: openim
bucket: openim # 存储内容桶
appBucket: app # 存储app的桶
location: us-east-1
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写

@ -25,10 +25,10 @@ func DelMsg(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
msgClient := pbChat.NewChatClient(grpcConn)
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
@ -39,5 +39,6 @@ func DelMsg(c *gin.Context) {
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}

@ -62,7 +62,6 @@ func SendMsg(c *gin.Context) {
params := paramsUserSendMsg{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
log.Error("0", "BindJSON failed ", err.Error())
return
}

@ -25,13 +25,13 @@ func SetConversation(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.Conversation = &pbUser.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetConversation(context.Background(), &reqPb)
@ -56,13 +56,13 @@ func ModifyConversationField(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.Conversation = &pbConversation.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
client := pbConversation.NewConversationClient(etcdConn)
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
@ -88,10 +88,10 @@ func BatchSetConversations(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
@ -120,10 +120,10 @@ func GetAllConversations(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
@ -152,10 +152,10 @@ func GetConversation(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversation(context.Background(), &reqPb)
@ -184,10 +184,10 @@ func GetConversations(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversations(context.Background(), &reqPb)
@ -216,10 +216,10 @@ func SetRecvMsgOpt(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)

@ -94,7 +94,7 @@ func ManagementSendMsg(c *gin.Context) {
params := ManagementSendMsgReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
return
}
switch params.ContentType {
@ -126,16 +126,16 @@ func ManagementSendMsg(c *gin.Context) {
//case constant.Quote:
default:
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
return
}
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
return
} else if err := validate.Struct(data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
log.ErrorByKv("data args validate err", "", "err", err.Error())
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
return
}
log.NewInfo("", data, params)

@ -12,7 +12,7 @@ import (
)
var (
minioClient *minio.Client
MinioClient *minio.Client
)
func MinioInit() {
@ -31,7 +31,7 @@ func MinioInit() {
return
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
MinioClient, err = minio.New(minioUrl.Host, &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
Secure: false,
})
@ -44,10 +44,25 @@ func MinioInit() {
Region: config.Config.Credential.Minio.Location,
ObjectLocking: false,
}
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists {
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else {
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
return
}
}
// make app bucket
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.AppBucket, opt)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists {
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else {
@ -59,7 +74,8 @@ func MinioInit() {
}
}
// 自动化桶public的代码
err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.AppBucket, policy.BucketPolicyReadWrite)
if err != nil {
log.NewDebug("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
return

@ -33,7 +33,7 @@ func MinioUploadFile(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
@ -61,7 +61,7 @@ func MinioUploadFile(c *gin.Context) {
}
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
@ -72,6 +72,7 @@ func MinioUploadFile(c *gin.Context) {
}
file, err := c.FormFile("file")
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
return
}
@ -83,10 +84,10 @@ func MinioUploadFile(c *gin.Context) {
}
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + err.Error()})
return
}
resp.NewName = newName
@ -106,7 +107,7 @@ func MinioStorageCredential(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)

@ -26,21 +26,18 @@ func GetUsersInfoFromCache(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(params.OperationID, "GetUsersInfoFromCache req: ", params)
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.GetUserInfo(context.Background(), req)
@ -54,117 +51,12 @@ func GetUsersInfoFromCache(c *gin.Context) {
publicUserInfoList = append(publicUserInfoList,
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
}
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
//func GetUsersInfoFromCache(c *gin.Context) {
// params := api.GetUsersInfoReq{}
// if err := c.BindJSON(&params); err != nil {
// log.NewError("0", "BindJSON failed ", err.Error())
// c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
// return
// }
// getUserInfoReq := &rpc.GetUserInfoReq{}
// getUserInfoReq.OperationID = params.OperationID
// var ok bool
// ok, getUserInfoReq.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), getUserInfoReq.OperationID)
// if !ok {
// log.NewError(getUserInfoReq.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
// }
// log.NewInfo(params.OperationID, "GetUserInfo args ", getUserInfoReq.String())
// reqCacheGetUserInfo := &cacheRpc.GetUserInfoFromCacheReq{}
// utils.CopyStructFields(reqCacheGetUserInfo, &params)
// var userInfoList []*open_im_sdk.UserInfo
// var publicUserInfoList []*open_im_sdk.PublicUserInfo
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
// cacheClient := cacheRpc.NewCacheClient(etcdConn)
// cacheResp, err := cacheClient.GetUserInfoFromCache(context.Background(), reqCacheGetUserInfo)
// if err != nil {
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", err.Error())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed: " + err.Error()})
// return
// }
// if cacheResp.CommonResp.ErrCode != 0 {
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", cacheResp.CommonResp)
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}
// resp.Data = []map[string]interface{}{}
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
// return
// }
// log.NewInfo(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "cacheResp:", cacheResp.String())
// userInfoList = cacheResp.UserInfoList
// var needCacheUserIDList []string
// for _, userID := range reqCacheGetUserInfo.UserIDList {
// isGetUserInfoFromCache := false
// for _, cacheUser := range userInfoList {
// if cacheUser.UserID == userID {
// isGetUserInfoFromCache = true
// }
// }
// if !isGetUserInfoFromCache {
// needCacheUserIDList = append(needCacheUserIDList, userID)
// }
// }
// if len(needCacheUserIDList) == 0 {
// log.NewInfo(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "get all userInfo from cache success")
// for _, v := range userInfoList {
// publicUserInfoList = append(publicUserInfoList,
// &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
// }
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
// resp.Data = jsonData.JsonDataList(resp.UserInfoList)
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
// return
// }
//
// log.NewDebug(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "need cache user list", needCacheUserIDList)
// getUserInfoReq.UserIDList = needCacheUserIDList
// etcdConn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
// client := rpc.NewUserClient(etcdConn)
// rpcResp, err := client.GetUserInfo(context.Background(), getUserInfoReq)
// if err != nil {
// log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error(), getUserInfoReq.String())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed" + err.Error()})
// return
// }
// if rpcResp.CommonResp.ErrCode != 0 {
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", cacheResp.CommonResp)
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}
// resp.Data = []map[string]interface{}{}
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
// return
// }
// userInfoList = append(userInfoList, rpcResp.UserInfoList...)
// cacheUpdateUserInfoReq := &cacheRpc.UpdateUserInfoToCacheReq{
// UserInfoList: rpcResp.UserInfoList,
// OperationID: getUserInfoReq.OperationID,
// }
// _, err = cacheClient.UpdateUserInfoToCache(context.Background(), cacheUpdateUserInfoReq)
// if err != nil {
// log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
// return
// }
// userInfoList = rpcResp.UserInfoList
// for _, v := range userInfoList {
// publicUserInfoList = append(publicUserInfoList,
// &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
// }
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
// resp.Data = jsonData.JsonDataList(resp.UserInfoList)
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
//}
func GetFriendIDListFromCache(c *gin.Context) {
var (
req api.GetFriendIDListFromCacheReq
@ -177,18 +69,17 @@ func GetFriendIDListFromCache(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
reqPb.OperationID = req.OperationID
var ok bool
var errInfo string
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
client := cacheRpc.NewCacheClient(etcdConn)
respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb)
@ -214,8 +105,8 @@ func GetBlackIDListFromCache(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.OperationID = req.OperationID
var ok bool
var errInfo string
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
@ -225,7 +116,6 @@ func GetBlackIDListFromCache(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
client := cacheRpc.NewCacheClient(etcdConn)
respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb)

@ -1,25 +1,29 @@
package admin
import (
"Open_IM/pkg/cms_api_struct"
apiStruct "Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
openIMHttp "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbAdmin "Open_IM/pkg/proto/admin_cms"
"Open_IM/pkg/utils"
"context"
"github.com/minio/minio-go/v7"
"net/http"
"strings"
"Open_IM/internal/api/third"
"github.com/gin-gonic/gin"
)
// register
func AdminLogin(c *gin.Context) {
var (
req cms_api_struct.AdminLoginRequest
resp cms_api_struct.AdminLoginResponse
req apiStruct.AdminLoginRequest
resp apiStruct.AdminLoginResponse
reqPb pbAdmin.AdminLoginReq
)
if err := c.BindJSON(&req); err != nil {
@ -40,3 +44,107 @@ func AdminLogin(c *gin.Context) {
resp.Token = respPb.Token
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func UploadUpdateApp(c *gin.Context) {
var (
req apiStruct.UploadUpdateAppReq
resp apiStruct.UploadUpdateAppResp
)
if err := c.Bind(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
newFileName, newYamlName, err := utils.GetUploadAppNewName(req.Type, req.Version)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file type" + err.Error()})
return
}
file, err := c.FormFile("file")
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "missing file arg", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
return
}
fileObj, err := file.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error:" + err.Error()})
return
}
yaml, err := c.FormFile("yaml")
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "missing yaml arg", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing yaml arg: " + err.Error()})
return
}
yamlObj, err := yaml.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open yaml failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error:" + err.Error()})
return
}
//fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", newFileName, newYamlName, fileObj, yamlObj, file.Size, yaml.Size)
// v2.0.9_app_linux v2.0.9_yaml_linux
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newFileName, fileObj, file.Size, minio.PutObjectOptions{})
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, yaml.Size, minio.PutObjectOptions{})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
return
}
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
resp.ErrCode = http.StatusInternalServerError
resp.ErrMsg = err.Error()
c.JSON(http.StatusInternalServerError, resp)
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName())
c.JSON(http.StatusOK, resp)
}
func GetDownloadURL(c *gin.Context) {
var (
req apiStruct.GetDownloadURLReq
resp apiStruct.GetDownloadURLResp
)
defer func() {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
}()
if err := c.Bind(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
fileName, yamlName, err := utils.GetUploadAppNewName(req.Type, req.Version)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file type" + err.Error()})
return
}
app, err := imdb.GetNewestVersion(req.Type)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "getNewestVersion failed" + err.Error()})
return
}
if app.Version != req.Version {
resp.Data.HasNewVersion = true
if app.ForceUpdate == true {
resp.Data.ForceUpdate = true
}
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + yamlName
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + fileName
c.JSON(http.StatusOK, resp)
} else {
resp.Data.HasNewVersion = false
c.JSON(http.StatusOK, resp)
}
}

@ -28,6 +28,7 @@ func GetGroupById(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
@ -44,6 +45,7 @@ func GetGroupById(c *gin.Context) {
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -58,6 +60,7 @@ func GetGroups(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.Pagination = &commonPb.RequestPagination{}
utils.CopyStructFields(&reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -83,6 +86,7 @@ func GetGroups(c *gin.Context) {
resp.GroupNums = int(respPb.GroupNum)
resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -97,6 +101,7 @@ func GetGroupByName(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupName = req.GroupName
reqPb.Pagination = &commonPb.RequestPagination{}
utils.CopyStructFields(&reqPb.Pagination, req)
@ -123,6 +128,7 @@ func GetGroupByName(c *gin.Context) {
resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.GroupNums = int(respPb.GroupNums)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -137,6 +143,7 @@ func CreateGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupInfo = &commonPb.GroupInfo{}
reqPb.GroupInfo.GroupName = req.GroupName
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
@ -169,6 +176,7 @@ func BanGroupChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupBanChat
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -193,6 +201,7 @@ func BanPrivateChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupBanPrivateChat
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -216,6 +225,7 @@ func OpenGroupChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupOk
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -239,6 +249,7 @@ func OpenPrivateChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupOk
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -263,6 +274,7 @@ func GetGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.Pagination = &commonPb.RequestPagination{
PageNumber: int32(req.PageNumber),
ShowNumber: int32(req.ShowNumber),
@ -290,6 +302,7 @@ func GetGroupMembers(c *gin.Context) {
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -304,6 +317,7 @@ func AddGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserIds = req.Members
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -316,6 +330,7 @@ func AddGroupMembers(c *gin.Context) {
}
resp.Success = respPb.Success
resp.Failed = respPb.Failed
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -330,6 +345,7 @@ func RemoveGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserIds = req.Members
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -342,6 +358,7 @@ func RemoveGroupMembers(c *gin.Context) {
}
resp.Success = respPb.Success
resp.Failed = respPb.Failed
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -356,6 +373,7 @@ func DeleteGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
@ -379,6 +397,7 @@ func SetGroupMaster(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.UserId = req.UserId
reqPb.RoleLevel = constant.GroupOwner
@ -404,6 +423,7 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.UserId = req.UserId
reqPb.RoleLevel = constant.GroupOrdinaryUsers
@ -424,6 +444,7 @@ func AlterGroupInfo(c *gin.Context) {
_ cms_api_struct.SetGroupMasterResponse
reqPb pbGroup.SetGroupInfoReq
)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)

@ -78,6 +78,7 @@ func GetChatLogs(c *gin.Context) {
ShowNumber: int32(req.ShowNumber),
}
utils.CopyStructFields(&reqPb, &req)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
client := pbMessage.NewMessageCMSClient(etcdConn)
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
@ -105,5 +106,6 @@ func GetChatLogs(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.ChatLogsNum = int(respPb.ChatLogsNum)
log.NewInfo("", utils.GetSelfFuncName(), "resp", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}

@ -20,6 +20,8 @@ func NewGinRouter() *gin.Engine {
adminRouterGroup := router.Group("/admin")
{
adminRouterGroup.POST("/login", admin.AdminLogin)
adminRouterGroup.POST("/upload_update_app", admin.UploadUpdateApp)
adminRouterGroup.POST("/get_download_url", admin.GetDownloadURL)
}
r2 := router.Group("")
r2.Use(middleware.JWTAuth())

@ -27,6 +27,7 @@ func GetMessagesStatistics(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -57,6 +58,7 @@ func GetMessagesStatistics(c *gin.Context) {
MessageNum: int(v.Num),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -72,6 +74,7 @@ func GetUserStatistics(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -112,6 +115,7 @@ func GetUserStatistics(c *gin.Context) {
TotalUserNum: int(v.Num),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -127,6 +131,7 @@ func GetGroupStatistics(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -160,6 +165,7 @@ func GetGroupStatistics(c *gin.Context) {
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -175,6 +181,7 @@ func GetActiveUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -185,6 +192,7 @@ func GetActiveUser(c *gin.Context) {
return
}
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -200,6 +208,7 @@ func GetActiveGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -220,5 +229,6 @@ func GetActiveGroup(c *gin.Context) {
MessageNum: int(group.MessageNum),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}

@ -29,6 +29,7 @@ func GetUserById(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -43,15 +44,17 @@ func GetUserById(c *gin.Context) {
return
}
utils.CopyStructFields(&resp, respPb.User)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetUsersByName(c *gin.Context) {
var (
req cms_api_struct.GetUsersByNameRequest
resp cms_api_struct.GetUsersByNameResponse
req cms_api_struct.GetUsersByNameRequest
resp cms_api_struct.GetUsersByNameResponse
reqPb pb.GetUsersByNameReq
)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
@ -74,6 +77,7 @@ func GetUsersByName(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -89,6 +93,7 @@ func GetUsers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.Pagination, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -101,6 +106,7 @@ func GetUsers(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -116,14 +122,15 @@ func ResignUser(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
fmt.Println(reqPb.UserId)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.ResignUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -138,6 +145,7 @@ func AlterUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -159,6 +167,7 @@ func AddUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -182,6 +191,7 @@ func BlockUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -205,6 +215,7 @@ func UnblockUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -213,6 +224,7 @@ func UnblockUser(c *gin.Context) {
openIMHttp.RespHttp200(c, err, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -229,6 +241,7 @@ func GetBlockUsers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.Pagination, &req)
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
@ -255,6 +268,7 @@ func GetBlockUsers(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -269,6 +283,7 @@ func GetBlockUserById(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserId = req.UserId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -281,6 +296,7 @@ func GetBlockUserById(c *gin.Context) {
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
utils.CopyStructFields(&resp, respPb.BlockUser.User)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -294,6 +310,7 @@ func DeleteUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserId = req.UserId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)

@ -21,7 +21,7 @@ type paramsVerificationCode struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
OperationID string `json:"operationID" binding:"required"`
UsedFor int `json:"usedFor"`
UsedFor int `json:"usedFor"`
}
func SendVerificationCode(c *gin.Context) {
@ -62,7 +62,7 @@ func SendVerificationCode(c *gin.Context) {
}
rand.Seed(time.Now().UnixNano())
code := 100000 + rand.Intn(900000)
log.NewInfo(params.OperationID, params.UsedFor,"begin store redis", accountKey, code)
log.NewInfo(params.OperationID, params.UsedFor, "begin store redis", accountKey, code)
err := db.DB.SetAccountCode(accountKey, code, config.Config.Demo.CodeTTL)
if err != nil {
log.NewError(params.OperationID, "set redis error", accountKey, "err", err.Error())
@ -77,7 +77,7 @@ func SendVerificationCode(c *gin.Context) {
m.SetHeader(`Subject`, config.Config.Demo.Mail.Title)
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
log.ErrorByKv("send mail error", account, "err", err.Error())
log.Error(params.OperationID, "send mail error", account, err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
return
}

@ -69,9 +69,6 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
rpcReq.UserID = m.SendID
rpcReq.OperationID = m.OperationID
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
if grpcConn == nil {
log.ErrorByKv("get grpcConn err", rpcReq.OperationID, "args", m)
}
msgClient := pbChat.NewChatClient(grpcConn)
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
if err != nil {

@ -62,11 +62,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
case constant.WSSendMsg:
data := open_im_sdk.MsgData{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}
@ -74,11 +74,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
case constant.WSSendSignalMsg:
data := pbRtc.SignalReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}
@ -86,11 +86,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
case constant.WSPullMsgBySeqList:
data := open_im_sdk.PullMessageBySeqListReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}

@ -45,7 +45,7 @@ func (ws *WServer) run() {
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
err := http.ListenAndServe(ws.wsAddr, nil) //Start listening
if err != nil {
log.ErrorByKv("Ws listening err", "", "err", err.Error())
panic("Ws listening err:" + err.Error())
}
}
@ -54,7 +54,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator
if err != nil {
log.ErrorByKv("upgrade http conn err", "", "err", err, query)
log.Error("", "upgrade http conn err", err, query)
return
} else {
//Connection mapping relationship,
@ -77,7 +77,7 @@ func (ws *WServer) readMsg(conn *UserConn) {
}
if err != nil {
uid, platform := ws.getUserUid(conn)
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
log.Error("", "WS ReadMsg error", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
userCount--
ws.delUserConn(conn)
return

@ -34,7 +34,7 @@ func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) {
log.NewDebug("", "msg come from kafka And push!!!", "msg", string(msg))
msgFromMQ := pbChat.PushMsgDataToMQ{}
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
log.ErrorByKv("push Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
log.Error("", "push Unmarshal msg err", "msg", string(msg), "err", err.Error())
return
}
//Call push module to send message to the user

@ -95,5 +95,6 @@ func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLogi
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}

@ -89,6 +89,7 @@ func SyncDB2Cache() error {
var err error
log.NewInfo("0", utils.GetSelfFuncName())
userList, err := imdb.GetAllUser()
log.NewDebug("", utils.GetSelfFuncName(), "userList", userList)
if err != nil {
return utils.Wrap(err, "")
}
@ -117,10 +118,10 @@ func updateAllUserToCache(userList []db.User) error {
}
m, err := utils.Pb2Map(userInfoPb)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error())
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
}
if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
@ -131,19 +132,19 @@ func updateAllGroupMemberListToCache() error {
log.NewInfo("0", utils.GetSelfFuncName())
groupIDList, err := imdb.GetAllGroupIDList()
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
panic(err.Error())
}
for _, groupID := range groupIDList {
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
log.NewWarn("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
continue
}
//log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList)
if len(groupMemberIDList) > 0 {
if err := db.DB.AddGroupMemberToCache(groupID, groupMemberIDList...); err != nil {
log.NewError("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
log.NewWarn("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
}
}
}
@ -156,13 +157,12 @@ func updateAllFriendToCache(userList []db.User) error {
for _, user := range userList {
friendIDList, err := imdb.GetFriendIDListByUserID(user.UserID)
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
continue
}
//log.NewDebug("", utils.GetSelfFuncName(), "friendIDList", user.UserID, friendIDList)
if len(friendIDList) > 0 {
if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID)
log.NewWarn("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID)
}
}
}
@ -175,13 +175,12 @@ func updateAllBlackListToCache(userList []db.User) error {
for _, user := range userList {
blackIDList, err := imdb.GetBlackIDListByUserID(user.UserID)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error())
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
continue
}
//log.NewDebug("", utils.GetSelfFuncName(), "updateAllBlackListToCache", user.UserID, blackIDList)
if len(blackIDList) > 0 {
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
}
}
}

@ -592,7 +592,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
}
resp := pbGroup.GetGroupsInfoResp{GroupInfoList: groupsInfoList}
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp)
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp.String())
return &resp, nil
}
@ -990,7 +990,8 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
for _, v := range groups {
groupMember, err := imdb.GetGroupMaster(v.GroupID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
continue
}
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
GroupInfo: &open_im_sdk.GroupInfo{
@ -1006,7 +1007,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
GroupMasterName: groupMember.Nickname,
})
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
return resp, nil
}
@ -1086,6 +1087,7 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
CurrentPage: req.Pagination.PageNumber,
ShowNumber: req.Pagination.ShowNumber,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp.String())
return resp, nil
}

@ -109,6 +109,7 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
chatLog.RecvID = req.GroupId
chatLog.SendID = req.UserId
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
nums, err := imdb.GetChatLogCount(chatLog)
resp.ChatLogsNum = int32(nums)
if err != nil {

@ -12,13 +12,6 @@ import (
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &commonPb.DelMsgListResp{}
//if err := db.DB.DelMsgLogic(req.UserID, req.SeqList, req.OperationID); err != nil {
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
// resp.ErrMsg = constant.ErrDB.ErrMsg
// resp.ErrCode = constant.ErrDB.ErrCode
// return resp, nil
//}
if err := db.DB.DelMsgBySeqList(req.UserID, req.SeqList, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
resp.ErrMsg = constant.ErrDB.ErrMsg

@ -42,7 +42,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
if err != nil {
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err.Error())
resp.ErrCode = 201
resp.ErrMsg = err.Error()
return resp, nil

@ -419,7 +419,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
func (rpc *rpcChat) sendMsgToKafka(m *pbChat.MsgDataToMQ, key string) error {
pid, offset, err := rpc.producer.SendMessage(m, key)
if err != nil {
log.ErrorByKv("kafka send failed", m.OperationID, "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key)
log.Error(m.OperationID, "kafka send failed", "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key)
}
return err
}

@ -146,10 +146,10 @@ func (s *officeServer) DeleteTag(_ context.Context, req *pbOffice.DeleteTagReq)
func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}}
IncreaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
increaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
reduceUserIDList := utils.RemoveRepeatedStringInList(req.ReduceUserIDList)
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, IncreaseUserIDList, reduceUserIDList); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", err.Error())
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, increaseUserIDList, reduceUserIDList); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", increaseUserIDList, reduceUserIDList, err.Error())
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
@ -174,13 +174,13 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
for _, groupID := range req.GroupList {
userIDList, err := im_mysql_model.GetGroupMemberIDListByGroupID(groupID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error(), groupID)
continue
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userIDList)
groupUserIDList = append(groupUserIDList, userIDList...)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
var userIDList []string
userIDList = append(userIDList, tagUserIDList...)
userIDList = append(userIDList, groupUserIDList...)
@ -191,13 +191,13 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
userIDList = append(userIDList[:i], userIDList[i+1:]...)
}
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
us, err := imdb.GetUserByUserID(req.SendID)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
user, err := imdb.GetUserByUserID(req.SendID)
if err != nil {
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.SendID)
}
for _, userID := range userIDList {
msg.TagSendMessage(req.OperationID, us, userID, req.Content, req.SenderPlatformID)
msg.TagSendMessage(req.OperationID, user, userID, req.Content, req.SenderPlatformID)
}
var tagSendLogs db.TagSendLog
for _, userID := range userIDList {
@ -216,7 +216,7 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
tagSendLogs.SenderPlatformID = req.SenderPlatformID
tagSendLogs.SendTime = time.Now().Unix()
if err := db.DB.SaveTagSendLog(&tagSendLogs); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", tagSendLogs, err.Error())
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
return resp, nil

@ -88,13 +88,14 @@ func (s *statisticsServer) Run() {
}
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
resp := &pbStatistics.GetActiveGroupResp{}
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
return resp, errors.WrapError(constant.ErrArgs)
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
@ -108,6 +109,7 @@ func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.G
MessageNum: int32(activeGroup.MessageNum),
})
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
return resp, nil
}
@ -119,6 +121,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
@ -133,6 +136,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
},
)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
return resp, nil
}
@ -232,7 +236,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
}
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
return resp, errors.WrapError(constant.ErrDB)
}
totalGroupNum, err := imdb.GetTotalGroupNum()
@ -243,7 +247,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
resp.IncreaseGroupNum = increaseGroupNum
resp.TotalGroupNum = totalGroupNum
times := GetRangeDate(fromTime, toTime)
log.NewInfo(req.OperationID, "times:", times)
log.NewDebug(req.OperationID, "times:", times)
wg := &sync.WaitGroup{}
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
@ -270,6 +274,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
}(wg, i, v)
}
wg.Wait()
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
@ -277,6 +282,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
resp := &pbStatistics.GetMessageStatisticsResp{}
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
return resp, errors.WrapError(constant.ErrArgs)
@ -291,6 +297,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
resp.PrivateMessageNum = privateMessageNum
resp.GroupMessageNum = groupMessageNum
times := GetRangeDate(fromTime, toTime)
@ -325,7 +332,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
}
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbStatistics.GetUserStatisticsResp{}
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
if err != nil {
@ -387,5 +394,6 @@ func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistic
}(wg, i, v)
}
wg.Wait()
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}

@ -16,7 +16,6 @@ import (
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"fmt"
"net"
"strconv"
"strings"
@ -170,6 +169,7 @@ func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAll
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbUser.Conversation{}}
conversations, err := imdb.GetUserAllConversations(req.OwnerUserID)
log.NewDebug(req.OperationID, "conversations: ", conversations)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
@ -187,6 +187,7 @@ func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConvers
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
@ -204,6 +205,7 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetConversationsResp{Conversations: []*pbUser.Conversation{}}
conversations, err := imdb.GetConversations(req.OwnerUserID, req.ConversationIDs)
log.NewDebug("", utils.GetSelfFuncName(), "conversations", conversations)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
@ -231,6 +233,7 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
return resp, nil
}
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "group status is dismissed", groupInfo)
errMsg := "group status is dismissed"
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
return resp, nil
@ -443,6 +446,7 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
CurrentPage: req.Pagination.PageNumber,
ShowNumber: req.Pagination.ShowNumber,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
@ -466,6 +470,7 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
CreateTime: user.CreateTime.String(),
IsBlock: isBlock,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
@ -474,6 +479,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
for _, v := range users {
@ -487,16 +493,19 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
IsBlock: isBlock,
}
resp.User = append(resp.User, user)
} else {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UserIsBlock failed", err.Error())
}
}
user := db.User{}
nums, err := imdb.GetUsersCount(user)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error(), user)
return resp, errors.WrapError(constant.ErrDB)
}
resp.UserNums = nums
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
@ -506,7 +515,7 @@ func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq)
}
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
log.NewInfo(req.OperationID, "AlterUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.AlterUserResp{}
user := db.User{
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
@ -519,11 +528,12 @@ func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*
return resp, errors.WrapError(constant.ErrDB)
}
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
log.NewInfo(req.OperationID, "AddUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.AddUserResp{}
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
if err != nil {
@ -534,8 +544,7 @@ func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUs
}
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
log.NewInfo(req.OperationID, "BlockUser args ", req.String())
fmt.Println("BlockUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.BlockUserResp{}
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
if err != nil {
@ -546,7 +555,7 @@ func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*
}
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
log.NewInfo(req.OperationID, "UnBlockUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.UnBlockUserResp{}
err := imdb.UnBlockUser(req.UserId)
if err != nil {
@ -557,7 +566,7 @@ func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq
}
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
log.NewInfo(req.OperationID, "GetBlockUsers args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetBlockUsersResp{}
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
@ -585,11 +594,12 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
return resp, errors.WrapError(constant.ErrDB)
}
resp.UserNums = nums
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetBlockUserByIdResp{}
user, err := imdb.GetBlockUserById(req.UserId)
if err != nil {
@ -606,6 +616,7 @@ func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUse
BeginDisableTime: (user.BeginDisableTime).String(),
EndDisableTime: (user.EndDisableTime).String(),
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
return resp, nil
}

@ -1,10 +1,43 @@
package cms_api_struct
import (
apiStruct "Open_IM/pkg/base_info"
)
type AdminLoginRequest struct {
AdminName string `json:"admin_name" binding:"required"`
Secret string `json:"secret" binding:"required"`
Secret string `json:"secret" binding:"required"`
}
type AdminLoginResponse struct {
Token string `json:"token"`
}
}
type UploadUpdateAppReq struct {
OperationID string `form:"operationID" binding:"required"`
Type int `form:"type" binding:"required"`
Version string `form:"version" binding:"required"`
//File multipart.FileHeader `form:"file" binding:"required"`
//Yaml multipart.FileHeader `form:"yaml" binding:"required"`
ForceUpdate bool `form:"forceUpdate" binding:"required"`
}
type UploadUpdateAppResp struct {
apiStruct.CommResp
}
type GetDownloadURLReq struct {
OperationID string `json:"operationID" binding:"required"`
Type int `json:"type" binding:"required"`
Version string `json:"version" binding:"required"`
}
type GetDownloadURLResp struct {
apiStruct.CommResp
Data struct {
HasNewVersion bool `json:"hasNewVersion"`
ForceUpdate bool `json:"forceUpdate"`
FileURL string `json:"fileURL"`
YamlURL string `json:"yamlURL"`
} `json:"data"`
}

@ -63,6 +63,7 @@ type config struct {
}
Minio struct {
Bucket string `yaml:"bucket"`
AppBucket string `yaml:"appBucket"`
Location string `yaml:"location"`
Endpoint string `yaml:"endpoint"`
AccessKeyID string `yaml:"accessKeyID"`

@ -268,4 +268,4 @@ const BigVersion = "v3"
const LogFileName = "OpenIM.log"
const StatisticsTimeInterval = 10
const StatisticsTimeInterval = 300

@ -272,3 +272,14 @@ type DepartmentMember struct {
func (DepartmentMember) TableName() string {
return "department_members"
}
type AppVersion struct {
Version string `gorm:"column:version;size:64"`
Type int `gorm:"column:type;primary_key"`
UpdateTime int `gorm:"column:update_time"`
ForceUpdate bool `gorm:"column:force_update"`
}
func (AppVersion) TableName() string {
return "app_version"
}

@ -119,7 +119,10 @@ func initMysqlDB() {
fmt.Println("CreateTable DepartmentMember")
db.CreateTable(&DepartmentMember{})
}
if !db.HasTable(&AppVersion{}) {
fmt.Println("CreateTable DepartmentMember")
db.CreateTable(&AppVersion{})
}
return
}

@ -0,0 +1,38 @@
package im_mysql_model
import (
"Open_IM/pkg/common/db"
"time"
)
func UpdateAppVersion(appType int, version string, forceUpdate bool) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
app := db.AppVersion{
Version: version,
Type: appType,
UpdateTime: int(time.Now().Unix()),
ForceUpdate: forceUpdate,
}
result := dbConn.Model(db.AppVersion{}).Where("app_type = ?", appType).Updates(&app)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
err := dbConn.Create(&app).Error
return err
}
return nil
}
func GetNewestVersion(appType int) (*db.AppVersion, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, err
}
dbConn.LogMode(true)
app := db.AppVersion{}
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
}

@ -13,6 +13,7 @@ type Statistics struct {
}
func (s *Statistics) output() {
var intervalCount uint64
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
defer t.Stop()
var sum uint64
@ -21,7 +22,12 @@ func (s *Statistics) output() {
select {
case <-t.C:
}
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.AllCount-sum, "total:", *s.AllCount)
if *s.AllCount-sum <= 0 {
intervalCount = 0
} else {
intervalCount = *s.AllCount - sum
}
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, intervalCount, "total:", *s.AllCount)
}
}

@ -2,6 +2,7 @@ package utils
import (
"Open_IM/pkg/common/constant"
"errors"
"fmt"
"math/rand"
"os"
@ -37,3 +38,33 @@ func GetNewFileNameAndContentType(fileName string, fileType int) (string, string
}
return newName, contentType
}
func GetUploadAppNewName(appType int, version string) (string, string, error) {
var newFileName, newYamlName = version + "_app_", version + "_yaml_"
switch appType {
case constant.IOSPlatformID:
newFileName += constant.IOSPlatformStr
newYamlName += constant.IOSPlatformStr
case constant.AndroidPlatformID:
newFileName += constant.AndroidPlatformStr
newYamlName += constant.AndroidPlatformStr
case constant.WindowsPlatformID:
newFileName += constant.WindowsPlatformStr
newYamlName += constant.WindowsPlatformStr
case constant.OSXPlatformID:
newFileName += constant.OSXPlatformStr
newYamlName += constant.OSXPlatformStr
case constant.WebPlatformID:
newFileName += constant.WebPlatformStr
newYamlName += constant.WebPlatformStr
case constant.MiniWebPlatformID:
newFileName += constant.MiniWebPlatformStr
newYamlName += constant.MiniWebPlatformStr
case constant.LinuxPlatformID:
newFileName += constant.LinuxPlatformStr
newYamlName += constant.LinuxPlatformStr
default:
return "", "", errors.New("invalid app type")
}
return newFileName, newYamlName, nil
}

Loading…
Cancel
Save