From 8c357ec213bb46ba995b9c0143d92080f93cea0d Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 16 Feb 2022 18:30:24 +0800 Subject: [PATCH 1/4] Refactoring code --- internal/api/third/tencent_cloud_storage_credential.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/api/third/tencent_cloud_storage_credential.go b/internal/api/third/tencent_cloud_storage_credential.go index 537641dee..02fc5c06e 100644 --- a/internal/api/third/tencent_cloud_storage_credential.go +++ b/internal/api/third/tencent_cloud_storage_credential.go @@ -61,5 +61,6 @@ func TencentCloudStorageCredential(c *gin.Context) { resp.Data.Region = config.Config.Credential.Tencent.Region resp.Data.CredentialResult = res } + log.NewInfo(req.OperationID, "TencentCloudStorageCredential return ", resp) c.JSON(http.StatusOK, resp) } From 3aadf61fde461c6124c5bb8fd24fcae4102c3f10 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 16 Feb 2022 18:58:02 +0800 Subject: [PATCH 2/4] Refactoring code --- pkg/base_info/cos_api_struct.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/base_info/cos_api_struct.go b/pkg/base_info/cos_api_struct.go index 41568e480..e3c0237a8 100644 --- a/pkg/base_info/cos_api_struct.go +++ b/pkg/base_info/cos_api_struct.go @@ -7,9 +7,9 @@ type TencentCloudStorageCredentialReq struct { } type TencentCloudStorageCredentialRespData struct { - *sts.CredentialResult - Region string `json:"region"` - Bucket string `json:"bucket"` + *sts.CredentialResult `json:"credentialResult"` + Region string `json:"region"` + Bucket string `json:"bucket"` } type TencentCloudStorageCredentialResp struct { From 17954dfdc926bb30d6fae28908c5b6c697cf8367 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 16 Feb 2022 19:41:44 +0800 Subject: [PATCH 3/4] Refactoring code --- .../api/third/tencent_cloud_storage_credential.go | 12 +++++++++--- pkg/base_info/cos_api_struct.go | 10 ++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/api/third/tencent_cloud_storage_credential.go b/internal/api/third/tencent_cloud_storage_credential.go index 02fc5c06e..d78d03b96 100644 --- a/internal/api/third/tencent_cloud_storage_credential.go +++ b/internal/api/third/tencent_cloud_storage_credential.go @@ -6,6 +6,9 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" "Open_IM/pkg/common/token_verify" + "github.com/fatih/structs" + + //"github.com/fatih/structs" "github.com/gin-gonic/gin" sts "github.com/tencentyun/qcloud-cos-sts-sdk/go" "net/http" @@ -57,10 +60,13 @@ func TencentCloudStorageCredential(c *gin.Context) { resp.ErrCode = constant.ErrTencentCredential.ErrCode resp.ErrMsg = err.Error() } else { - resp.Data.Bucket = config.Config.Credential.Tencent.Bucket - resp.Data.Region = config.Config.Credential.Tencent.Region - resp.Data.CredentialResult = res + resp.CosData.Bucket = config.Config.Credential.Tencent.Bucket + resp.CosData.Region = config.Config.Credential.Tencent.Region + resp.CosData.CredentialResult = res } + + resp.Data = structs.Map(&resp.CosData) log.NewInfo(req.OperationID, "TencentCloudStorageCredential return ", resp) + c.JSON(http.StatusOK, resp) } diff --git a/pkg/base_info/cos_api_struct.go b/pkg/base_info/cos_api_struct.go index e3c0237a8..e35931ad9 100644 --- a/pkg/base_info/cos_api_struct.go +++ b/pkg/base_info/cos_api_struct.go @@ -7,12 +7,14 @@ type TencentCloudStorageCredentialReq struct { } type TencentCloudStorageCredentialRespData struct { - *sts.CredentialResult `json:"credentialResult"` - Region string `json:"region"` - Bucket string `json:"bucket"` + *sts.CredentialResult + Region string `json:"region"` + Bucket string `json:"bucket"` } type TencentCloudStorageCredentialResp struct { CommResp - Data TencentCloudStorageCredentialRespData `json:"data"` + CosData TencentCloudStorageCredentialRespData `json:"-"` + + Data map[string]interface{} `json:"data"` } From 3b73a4c69a2eda2e57ac800cb54d305323a2a8d3 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 17 Feb 2022 11:13:51 +0800 Subject: [PATCH 4/4] send msg modify --- internal/api/third/tencent_cloud_storage_credential.go | 1 + internal/rpc/msg/send_msg.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/api/third/tencent_cloud_storage_credential.go b/internal/api/third/tencent_cloud_storage_credential.go index 537641dee..b7b522ea1 100644 --- a/internal/api/third/tencent_cloud_storage_credential.go +++ b/internal/api/third/tencent_cloud_storage_credential.go @@ -61,5 +61,6 @@ func TencentCloudStorageCredential(c *gin.Context) { resp.Data.Region = config.Config.Credential.Tencent.Region resp.Data.CredentialResult = res } + log.NewInfo(req.OperationID, "TencentCloudStorageCredential return", resp) c.JSON(http.StatusOK, resp) } diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 4f57e6406..281ac2ed3 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -250,7 +250,7 @@ func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32, func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *pbChat.SendMsgReq) bool { conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType) opt, err := db.DB.GetSingleConversationMsgOpt(userID, conversationID) - if err != nil || err != redis.ErrNil { + if err != nil && err != redis.ErrNil { log.NewError(pb.OperationID, "GetSingleConversationMsgOpt from redis err", conversationID, pb.String(), err.Error()) return true }