diff --git a/config/config.yaml b/config/config.yaml index 0d2493604..ae607f9f6 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -132,7 +132,7 @@ api: # minio.signEndpoint is minio public network address object: enable: "minio" - apiURL: "http://http://127.0.0.1:10002" + apiURL: "http://127.0.0.1:10002" minio: bucket: "openim" endpoint: "http://172.28.0.1:10005" diff --git a/go.sum b/go.sum index 5b180156e..23ac482b8 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIw github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/IBM/sarama v1.41.1 h1:B4/TdHce/8Ipza+qrLIeNJ9D1AOxZVp/3uDv6H/dp2M= github.com/IBM/sarama v1.41.1/go.mod h1:JFCPURVskaipJdKRFkiE/OZqQHw7jqliaJmRwXCmSSw= -github.com/OpenIMSDK/protocol v0.0.21 h1:5H6H+hJ9d/VgRqttvxD/zfK9Asd+4M8Eknk5swSbUVY= -github.com/OpenIMSDK/protocol v0.0.21/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.23 h1:L545aRQez6Ro+AaJB1Z6Mz7ojnDtp41WqASxYveCkcE= +github.com/OpenIMSDK/protocol v0.0.23/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ= github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= diff --git a/internal/api/msg.go b/internal/api/msg.go index 83949903e..b9b10e98e 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -100,6 +100,7 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg) ContentType: params.ContentType, Content: []byte(newContent), CreateTime: utils.GetCurrentTimestampByMill(), + SendTime: params.SendTime, Options: options, OfflinePushInfo: params.OfflinePushInfo, }, @@ -207,7 +208,6 @@ func (m *MessageApi) SendMessage(c *gin.Context) { apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap()) return } - log.ZInfo(c, "SendMessage", "req", req) if !authverify.IsAppManagerUid(c) { apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message")) return @@ -224,6 +224,7 @@ func (m *MessageApi) SendMessage(c *gin.Context) { respPb, err := m.Client.SendMsg(c, sendMsgReq) if err != nil { status = constant.MsgSendFailed + log.ZError(c, "send message err", err) apiresp.GinError(c, err) return } diff --git a/internal/rpc/third/log.go b/internal/rpc/third/log.go index b56d82f0f..1bbf168a9 100644 --- a/internal/rpc/third/log.go +++ b/internal/rpc/third/log.go @@ -11,6 +11,7 @@ import ( "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/utils" utils2 "github.com/OpenIMSDK/tools/utils" + "github.com/openimsdk/open-im-server/v3/pkg/authverify" relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" ) diff --git a/pkg/apistruct/manage.go b/pkg/apistruct/manage.go index eef38e403..7d30d2151 100644 --- a/pkg/apistruct/manage.go +++ b/pkg/apistruct/manage.go @@ -29,6 +29,7 @@ type SendMsg struct { SessionType int32 `json:"sessionType" binding:"required"` IsOnlineOnly bool `json:"isOnlineOnly"` NotOfflinePush bool `json:"notOfflinePush"` + SendTime int64 `json:"sendTime"` OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"` } diff --git a/pkg/common/db/controller/third.go b/pkg/common/db/controller/third.go index 247dfb408..b97edd7aa 100644 --- a/pkg/common/db/controller/third.go +++ b/pkg/common/db/controller/third.go @@ -18,10 +18,11 @@ import ( "context" "time" + "gorm.io/gorm" + "github.com/openimsdk/open-im-server/v3/pkg/common/db/cache" dbimpl "github.com/openimsdk/open-im-server/v3/pkg/common/db/relation" "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" - "gorm.io/gorm" ) type ThirdDatabase interface { diff --git a/pkg/common/db/relation/log_model.go b/pkg/common/db/relation/log_model.go index 4508297c2..8ca9579f7 100644 --- a/pkg/common/db/relation/log_model.go +++ b/pkg/common/db/relation/log_model.go @@ -6,8 +6,9 @@ import ( "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/ormutil" - relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" "gorm.io/gorm" + + relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" ) type LogGorm struct { diff --git a/tools/component/component.go b/tools/component/component.go index 04c6ba9a5..df5849b51 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -22,7 +22,6 @@ import ( "net" "net/url" "os" - "strings" "time" "github.com/minio/minio-go/v7" @@ -117,16 +116,24 @@ func main() { os.Exit(1) } -func exactIP(urll string) string { - u, _ := url.Parse(urll) - host, _, err := net.SplitHostPort(u.Host) - if err != nil { - host = u.Host +func checkMinioIP() error { + for _, i := range []string{config.Config.Object.ApiURL, config.Config.Object.Minio.SignEndpoint} { + u, err := url.Parse(i) + if err != nil { + return utils.Wrap(err, "api format error,please check config file apiURL or Minio SignEndpoint") + } + if u.Scheme == "https" { + continue + } + host, _, err := net.SplitHostPort(u.Host) + if err != nil { + host = u.Host + } + if host == "127.0.0.1" { + return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1,please modify it") + } } - if strings.HasSuffix(host, ":") { - host = host[0 : len(host)-1] - } - return host + return nil } func checkMysql() error { @@ -205,8 +212,8 @@ func checkMinio() error { return ErrComponentStart.Wrap("Minio server is offline") } } - if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.SignEndpoint) == "127.0.0.1" { - return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1") + if checkMinioIP() != nil { + return checkMinioIP() } } return nil