/pkg-make lint (#1956)

Signed-off-by: longyuqing112 <105913803+longyuqing112@users.noreply.github.com>
pull/1955/head
longyuqing112 9 months ago committed by GitHub
parent c8eed84711
commit 4803c8f004
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -133,7 +133,6 @@ func NewSeqCmd() *SeqCmd {
return seqCmd return seqCmd
} }
func (s *SeqCmd) GetSeqCmd() *cobra.Command { func (s *SeqCmd) GetSeqCmd() *cobra.Command {
s.Command.Run = func(cmdLines *cobra.Command, args []string) { s.Command.Run = func(cmdLines *cobra.Command, args []string) {
_, err := tools.InitMsgTool() _, err := tools.InitMsgTool()

@ -70,7 +70,7 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
} }
} }
if len(deleteTokenKey) != 0 { if len(deleteTokenKey) != 0 {
err := a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey) err = a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey)
if err != nil { if err != nil {
return "", err return "", err
} }

@ -149,7 +149,7 @@ func (m *Minio) initMinio(ctx context.Context) error {
`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, `{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`,
conf.Bucket, conf.Bucket,
) )
if err := m.core.Client.SetBucketPolicy(ctx, conf.Bucket, policy); err != nil { if err = m.core.Client.SetBucketPolicy(ctx, conf.Bucket, policy); err != nil {
return err return err
} }
} }

@ -82,7 +82,8 @@ func (m *Minio) getImageThumbnailURL(ctx context.Context, name string, expire ti
} }
key, err := m.cache.GetThumbnailKey(ctx, name, opt.Format, opt.Width, opt.Height, func(ctx context.Context) (string, error) { key, err := m.cache.GetThumbnailKey(ctx, name, opt.Format, opt.Width, opt.Height, func(ctx context.Context) (string, error) {
if img == nil { if img == nil {
reader, err := m.core.Client.GetObject(ctx, m.bucket, name, minio.GetObjectOptions{}) var reader *minio.Object
reader, err = m.core.Client.GetObject(ctx, m.bucket, name, minio.GetObjectOptions{})
if err != nil { if err != nil {
return "", err return "", err
} }
@ -103,7 +104,7 @@ func (m *Minio) getImageThumbnailURL(ctx context.Context, name string, expire ti
err = gif.Encode(buf, thumbnail, nil) err = gif.Encode(buf, thumbnail, nil)
} }
cacheKey := filepath.Join(imageThumbnailPath, info.Etag, fmt.Sprintf("image_w%d_h%d.%s", opt.Width, opt.Height, opt.Format)) cacheKey := filepath.Join(imageThumbnailPath, info.Etag, fmt.Sprintf("image_w%d_h%d.%s", opt.Width, opt.Height, opt.Format))
if _, err := m.core.Client.PutObject(ctx, m.bucket, cacheKey, buf, int64(buf.Len()), minio.PutObjectOptions{}); err != nil { if _, err = m.core.Client.PutObject(ctx, m.bucket, cacheKey, buf, int64(buf.Len()), minio.PutObjectOptions{}); err != nil {
return "", err return "", err
} }
return cacheKey, nil return cacheKey, nil

@ -52,10 +52,10 @@ const (
const successCode = http.StatusOK const successCode = http.StatusOK
const ( /* const (
videoSnapshotImagePng = "png" videoSnapshotImagePng = "png"
videoSnapshotImageJpg = "jpg" videoSnapshotImageJpg = "jpg"
) ) */
func NewOSS() (s3.Interface, error) { func NewOSS() (s3.Interface, error) {
conf := config.Config.Object.Oss conf := config.Config.Object.Oss

@ -246,47 +246,42 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(
indexs = append(indexs, m.model.GetMsgIndex(seq)) indexs = append(indexs, m.model.GetMsgIndex(seq))
} }
pipeline := mongo.Pipeline{ pipeline := mongo.Pipeline{
{ bson.D{{Key: "$match", Value: bson.D{
{"$match", bson.D{ {Key: "doc_id", Value: docID},
{"doc_id", docID}, }}},
}}, bson.D{{Key: "$project", Value: bson.D{
}, {Key: "_id", Value: 0},
{ {Key: "doc_id", Value: 1},
{"$project", bson.D{ {Key: "msgs", Value: bson.D{
{"_id", 0}, {Key: "$map", Value: bson.D{
{"doc_id", 1}, {Key: "input", Value: indexs},
{"msgs", bson.D{ {Key: "as", Value: "index"},
{"$map", bson.D{ {Key: "in", Value: bson.D{
{"input", indexs}, {Key: "$let", Value: bson.D{
{"as", "index"}, {Key: "vars", Value: bson.D{
{"in", bson.D{ {Key: "currentMsg", Value: bson.D{
{"$let", bson.D{ {Key: "$arrayElemAt", Value: bson.A{"$msgs", "$$index"}},
{"vars", bson.D{
{"currentMsg", bson.D{
{"$arrayElemAt", []string{"$msgs", "$$index"}},
}},
}}, }},
{"in", bson.D{ }},
{"$cond", bson.D{ {Key: "in", Value: bson.D{
{"if", bson.D{ {Key: "$cond", Value: bson.D{
{"$in", []string{userID, "$$currentMsg.del_list"}}, {Key: "if", Value: bson.D{
}}, {Key: "$in", Value: bson.A{userID, "$$currentMsg.del_list"}},
{"then", nil},
{"else", "$$currentMsg"},
}}, }},
{Key: "then", Value: nil},
{Key: "else", Value: "$$currentMsg"},
}}, }},
}}, }},
}}, }},
}}, }},
}}, }},
}}, }},
}, }}},
{ bson.D{{Key: "$project", Value: bson.D{
{"$project", bson.D{ {Key: "msgs.del_list", Value: 0},
{"msgs.del_list", 0}, }}},
}},
},
} }
cur, err := m.MsgCollection.Aggregate(ctx, pipeline) cur, err := m.MsgCollection.Aggregate(ctx, pipeline)
if err != nil { if err != nil {
return nil, errs.Wrap(err) return nil, errs.Wrap(err)
@ -800,7 +795,7 @@ func (m *MsgMongoDriver) RangeUserSendCount(
} }
defer cur.Close(ctx) defer cur.Close(ctx)
var result []Result var result []Result
if err := cur.All(ctx, &result); err != nil { if err = cur.All(ctx, &result); err != nil {
return 0, 0, nil, nil, errs.Wrap(err) return 0, 0, nil, nil, errs.Wrap(err)
} }
if len(result) == 0 { if len(result) == 0 {
@ -1049,7 +1044,7 @@ func (m *MsgMongoDriver) RangeGroupSendCount(
} }
defer cur.Close(ctx) defer cur.Close(ctx)
var result []Result var result []Result
if err := cur.All(ctx, &result); err != nil { if err = cur.All(ctx, &result); err != nil {
return 0, 0, nil, nil, errs.Wrap(err) return 0, 0, nil, nil, errs.Wrap(err)
} }
if len(result) == 0 { if len(result) == 0 {

@ -410,7 +410,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
return err return err
} }
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg} tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg}
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil { if err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err return err
} }
for _, userID := range append(userIDs, req.FromUserID) { for _, userID := range append(userIDs, req.FromUserID) {
@ -443,7 +443,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
return err return err
} }
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg} tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil { if err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err return err
} }
for _, userID := range append(userIDs, req.FromUserID) { for _, userID := range append(userIDs, req.FromUserID) {

@ -42,13 +42,15 @@ func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
} }
client := third.NewThirdClient(conn) client := third.NewThirdClient(conn)
minioClient, err := minioInit() minioClient, err := minioInit()
if err != nil {
panic(err)
}
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient} return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
} }
func minioInit() (*minio.Client, error) { func minioInit() (*minio.Client, error) {
minioClient := &minio.Client{} minioClient := &minio.Client{}
var initUrl string initUrl := config.Config.Object.Minio.Endpoint
initUrl = config.Config.Object.Minio.Endpoint
minioUrl, err := url.Parse(initUrl) minioUrl, err := url.Parse(initUrl)
if err != nil { if err != nil {
return nil, err return nil, err

@ -36,9 +36,7 @@ func (s *Statistics) output() {
var timeIntervalNum uint64 var timeIntervalNum uint64
for { for {
sum = *s.AllCount sum = *s.AllCount
select { <-t.C
case <-t.C:
}
if *s.AllCount-sum <= 0 { if *s.AllCount-sum <= 0 {
intervalCount = 0 intervalCount = 0
} else { } else {

Loading…
Cancel
Save