diff --git a/.golangci.yml b/.golangci.yml index d588695dd..3dad0af30 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -361,13 +361,17 @@ linters-settings: - gorm.io/gorm - gorm.io/driver/mysql - k8s.io/klog + - github.com/allowed/module + - go.mongodb.org/mongo-driver/mongo # - gopkg.in/yaml.v2 domains: # List of allowed module domains - google.golang.org - gopkg.in - golang.org - github.com + - go.mongodb.org - go.uber.org + - openim.io - go.etcd.io blocked: versions: diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index cf452450c..17a7c4724 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -61,11 +61,11 @@ func run(port int) error { if err != nil { return err } - if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil { + if err = client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil { return err } fmt.Println("api register public config to discov") - if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil { + if err = client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil { return err } fmt.Println("api register public config to discov success") @@ -82,7 +82,9 @@ func run(port int) error { err = router.Run(address) if err != nil { log.ZError(context.Background(), "api run failed ", err, "address", address) + return err } + return nil } diff --git a/internal/api/third.go b/internal/api/third.go index 8c4fddb67..cdb059cc0 100644 --- a/internal/api/third.go +++ b/internal/api/third.go @@ -106,7 +106,7 @@ func (o *ThirdApi) ObjectRedirect(c *gin.Context) { c.Redirect(http.StatusFound, resp.Url) } -// #################### logs #################### +// #################### logs ####################. func (o *ThirdApi) UploadLogs(c *gin.Context) { a2r.Call(third.ThirdClient.UploadLogs, o.Client, c) } diff --git a/internal/msggateway/long_conn.go b/internal/msggateway/long_conn.go index f7676aec1..604619eb5 100644 --- a/internal/msggateway/long_conn.go +++ b/internal/msggateway/long_conn.go @@ -120,6 +120,7 @@ func (d *GWebSocket) SetReadLimit(limit int64) { func (d *GWebSocket) SetPongHandler(handler PingPongHandler) { d.conn.SetPongHandler(handler) } + func (d *GWebSocket) SetPingHandler(handler PingPongHandler) { d.conn.SetPingHandler(handler) } diff --git a/internal/rpc/third/log.go b/internal/rpc/third/log.go index 1bbf168a9..aa83f58f7 100644 --- a/internal/rpc/third/log.go +++ b/internal/rpc/third/log.go @@ -69,7 +69,6 @@ func (t *thirdServer) UploadLogs(ctx context.Context, req *third.UploadLogsReq) } func (t *thirdServer) DeleteLogs(ctx context.Context, req *third.DeleteLogsReq) (*third.DeleteLogsResp, error) { - if err := authverify.CheckAdmin(ctx); err != nil { return nil, err } diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go index a21168b55..d755de645 100644 --- a/pkg/common/db/cache/conversation.go +++ b/pkg/common/db/cache/conversation.go @@ -414,7 +414,8 @@ func (c *ConversationRedisCache) GetUserAllHasReadSeqs( } func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, - conversationIDs ...string) ConversationCache { + conversationIDs ...string, +) ConversationCache { cache := c.NewCache() for _, conversationID := range conversationIDs { cache.AddKeys(c.getConversationHasReadSeqKey(ownerUserID, conversationID)) diff --git a/pkg/common/db/controller/third.go b/pkg/common/db/controller/third.go index b97edd7aa..971719b1f 100644 --- a/pkg/common/db/controller/third.go +++ b/pkg/common/db/controller/third.go @@ -28,7 +28,7 @@ import ( type ThirdDatabase interface { FcmUpdateToken(ctx context.Context, account string, platformID int, fcmToken string, expireTime int64) error SetAppBadge(ctx context.Context, userID string, value int) error - //about log for debug + // about log for debug UploadLogs(ctx context.Context, logs []*relation.Log) error DeleteLogs(ctx context.Context, logID []string, userID string) error SearchLogs(ctx context.Context, keyword string, start time.Time, end time.Time, pageNumber int32, showNumber int32) (uint32, []*relation.Log, error) @@ -60,7 +60,6 @@ func (t *thirdDatabase) GetLogs(ctx context.Context, LogIDs []string, userID str // SearchLogs implements ThirdDatabase. func (t *thirdDatabase) SearchLogs(ctx context.Context, keyword string, start time.Time, end time.Time, pageNumber int32, showNumber int32) (uint32, []*relation.Log, error) { return t.logdb.Search(ctx, keyword, start, end, pageNumber, showNumber) - } // UploadLogs implements ThirdDatabase. diff --git a/pkg/common/db/relation/log_model.go b/pkg/common/db/relation/log_model.go index 8ca9579f7..bf39512e8 100644 --- a/pkg/common/db/relation/log_model.go +++ b/pkg/common/db/relation/log_model.go @@ -41,6 +41,7 @@ func (l *LogGorm) Get(ctx context.Context, logIDs []string, userID string) ([]*r } return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Find(&logs).Error) } + func NewLogGorm(db *gorm.DB) relationtb.LogInterface { db.AutoMigrate(&relationtb.Log{}) return &LogGorm{db: db} diff --git a/tools/component/component.go b/tools/component/component.go index 04c6ba9a5..9aecfa704 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -46,7 +46,7 @@ import ( ) const ( - // defaultCfgPath is the default path of the configuration file + // defaultCfgPath is the default path of the configuration file. defaultCfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 maxRetry = 100 @@ -66,6 +66,7 @@ func initCfg() error { if err != nil { return err } + return yaml.Unmarshal(data, &config.Config) } @@ -79,6 +80,7 @@ func main() { if err := initCfg(); err != nil { fmt.Printf("Read config failed: %v\n", err) + return } @@ -111,6 +113,7 @@ func main() { if allSuccess { successPrint("All components started successfully!") + return } } @@ -126,9 +129,11 @@ func exactIP(urll string) string { if strings.HasSuffix(host, ":") { host = host[0 : len(host)-1] } + return host } + func checkMysql() error { var sqlDB *sql.DB defer func() { @@ -148,6 +153,7 @@ func checkMysql() error { return errs.Wrap(err) } } + return nil } @@ -177,6 +183,7 @@ func checkMongo() error { return errs.Wrap(err) } } + return nil } @@ -209,6 +216,7 @@ func checkMinio() error { return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1") } } + return nil } @@ -236,6 +244,7 @@ func checkRedis() error { if err != nil { return errs.Wrap(err) } + return nil } @@ -260,6 +269,7 @@ func checkZookeeper() error { return errs.Wrap(err) } } + return nil } @@ -295,6 +305,7 @@ func checkKafka() error { return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic)) } } + return nil }