feat: format openim config constran

This commit is contained in:
Xinwei Xiong(cubxxw) 2024-03-19 15:42:20 +08:00 committed by Xinwei Xiong (cubxxw)
parent 7b262510f5
commit 1132bce252
16 changed files with 61 additions and 43 deletions

View File

@ -174,6 +174,11 @@ linters-settings:
# - ^print.*$
- 'fmt\.Print.*'
- fmt.Println.* # too much log noise
- ^unsafe\..*$
- ^init$
- ^os.Exit$
- ^fmt.Print.*$
- ^panic$
- painc
# - ginkgo\\.F.* # these are used just for local development
# # Exclude godoc examples from forbidigo checks. Default is true.
@ -239,9 +244,6 @@ linters-settings:
hugeParam:
# size in bytes that makes the warning trigger (default 80)
sizeThreshold: 80
nestingReduce:
# min number of statements inside a branch to trigger a warning (default 5)
bodyWidth: 5
rangeExprCopy:
# size in bytes that makes the warning trigger (default 512)
sizeThreshold: 512
@ -255,15 +257,10 @@ linters-settings:
ruleguard:
# path to a gorules file for the ruleguard checker
rules: ''
truncateCmp:
# whether to skip int/uint/uintptr types (default true)
skipArchDependent: true
underef:
# whether to skip (*x).method() calls where x is a pointer receiver (default true)
skipRecvDeref: true
unnamedResult:
# whether to check exported functions
checkExported: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30

View File

@ -119,7 +119,7 @@ func (o *GroupApi) GetGroupAbstractInfo(c *gin.Context) {
// a2r.Call(group.GroupClient.SetGroupMemberNickname, g.userClient, c)
//}
//
//func (g *Group) GetGroupAllMemberList(c *gin.Context) {
// func (g *Group) GetGroupAllMemberList(c *gin.Context) {
// a2r.Call(group.GroupClient.GetGroupAllMember, g.userClient, c)
//}

View File

@ -33,7 +33,7 @@ func (a *Audience) set(key string, v []string) {
a.Object = a.audience
}
// v, ok = this.audience[key]
//if ok {
// if ok {
// return
//}
a.audience[key] = v

View File

@ -315,10 +315,10 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
// Get user IDs with "Do Not Disturb" enabled in super large groups.
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbconversation.GetRecvMsgNotNotifyUserIDsReq) (*pbconversation.GetRecvMsgNotNotifyUserIDsResp, error) {
// userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
//if err != nil {
// if err != nil {
// return nil, err
//}
//return &pbconversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
// return &pbconversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
return nil, errors.New("deprecated")
}

View File

@ -25,8 +25,6 @@ import (
var Config GlobalConfig
const ConfKey = "conf"
type CallBackConfig struct {
Enable bool `yaml:"enable"`
CallbackTimeOut int `yaml:"timeout"`

View File

@ -0,0 +1,23 @@
package config
const ConfKey = "conf"
const (
// DefaultDirPerm is used for creating general directories, allowing the owner to read, write, and execute,
// while the group and others can only read and execute.
DefaultDirPerm = 0755
// PrivateFilePerm is used for sensitive files, allowing only the owner to read and write.
PrivateFilePerm = 0600
// ExecFilePerm is used for executable files, allowing the owner to read, write, and execute,
// while the group and others can only read.
ExecFilePerm = 0754
// SharedDirPerm is used for shared directories, allowing the owner and group to read, write, and execute,
// with no permissions for others.
SharedDirPerm = 0770
// ReadOnlyDirPerm is used for read-only directories, allowing the owner, group, and others to only read.
ReadOnlyDirPerm = 0555
)

View File

@ -31,9 +31,9 @@ import (
const (
// ConversationKey = "CONVERSATION:"
//conversationIDsKey = "CONVERSATION_IDS:"
//conversationIDsHashKey = "CONVERSATION_IDS_HASH:"
//conversationHasReadSeqKey = "CONVERSATION_HAS_READ_SEQ:"
// conversationIDsKey = "CONVERSATION_IDS:"
// conversationIDsHashKey = "CONVERSATION_IDS_HASH:"
// conversationHasReadSeqKey = "CONVERSATION_HAS_READ_SEQ:"
//recvMsgOptKey = "RECV_MSG_OPT:"
//superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
//superGroupRecvMsgNotNotifyUserIDsHashKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS_HASH:"
@ -108,7 +108,7 @@ type ConversationRedisCache struct {
// rdb redis.UniversalClient,
// conversationDB *relation.ConversationGorm,
// options rockscache.Options,
//) ConversationCache {
// ) ConversationCache {
// rcClient := rockscache.NewClient(rdb, options)
//
// return &ConversationRedisCache{
@ -237,10 +237,10 @@ func (c *ConversationRedisCache) DelConversations(ownerUserID string, conversati
func (c *ConversationRedisCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationtb.ConversationModel, error) {
// var keys []string
//for _, conversarionID := range conversationIDs {
// for _, conversarionID := range conversationIDs {
// keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
//}
//return batchGetCache(
// return batchGetCache(
// ctx,
// c.rcClient,
// keys,
@ -263,10 +263,10 @@ func (c *ConversationRedisCache) GetUserAllConversations(ctx context.Context, ow
return nil, err
}
// var keys []string
//for _, conversarionID := range conversationIDs {
// for _, conversarionID := range conversationIDs {
// keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
//}
//return batchGetCache(
// return batchGetCache(
// ctx,
// c.rcClient,
// keys,

View File

@ -30,8 +30,8 @@ import (
const (
friendExpireTime = time.Second * 60 * 60 * 12
// FriendIDsKey = "FRIEND_IDS:"
//TwoWayFriendsIDsKey = "COMMON_FRIENDS_IDS:"
//friendKey = "FRIEND_INFO:".
// TwoWayFriendsIDsKey = "COMMON_FRIENDS_IDS:"
// friendKey = "FRIEND_INFO:".
)
// FriendCache is an interface for caching friend-related data.

View File

@ -33,9 +33,9 @@ import (
const (
groupExpireTime = time.Second * 60 * 60 * 12
// GroupInfoKey = "GROUP_INFO:"
//groupMemberIDsKey = "GROUP_MEMBER_IDS:"
//groupMembersHashKey = "GROUP_MEMBERS_HASH2:"
//groupMemberInfoKey = "GROUP_MEMBER_INFO:"
// groupMemberIDsKey = "GROUP_MEMBER_IDS:"
// groupMembersHashKey = "GROUP_MEMBERS_HASH2:"
// groupMemberInfoKey = "GROUP_MEMBER_INFO:"
//joinedGroupsKey = "JOIN_GROUPS_KEY:"
//groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:"
//groupRoleLevelMemberIDsKey = "GROUP_ROLE_LEVEL_MEMBER_IDS:".

View File

@ -247,7 +247,7 @@ func batchGetCache2[T any, K comparable](
// expire time.Duration,
// keyIndexFn func(s string, keys []string) (int, error),
// fn func(ctx context.Context) (map[string]T, error),
//) (map[string]T, error) {
// ) (map[string]T, error) {
// batchMap, err := rcClient.FetchBatch2(ctx, keys, expire, func(idxs []int) (m map[int]string, err error) {
// tArrays, err := fn(ctx)
// if err != nil {

View File

@ -42,7 +42,7 @@ const (
getuiToken = "GETUI_TOKEN"
getuiTaskID = "GETUI_TASK_ID"
// SignalCache = "SIGNAL_CACHE:"
//signalListCache = "SIGNAL_LIST_CACHE:".
// signalListCache = "SIGNAL_LIST_CACHE:".
FCM_TOKEN = "FCM_TOKEN:"
messageCache = "MESSAGE_CACHE:"
@ -508,7 +508,7 @@ func (c *msgCache) UserDeleteMsgs(ctx context.Context, conversationID string, se
return nil
// pipe := c.rdb.Pipeline()
//for _, seq := range seqs {
// for _, seq := range seqs {
// delUserListKey := c.getMessageDelUserListKey(conversationID, seq)
// userDelListKey := c.getUserDelList(conversationID, userID)
// err := pipe.SAdd(ctx, delUserListKey, userID).Err()
@ -526,8 +526,8 @@ func (c *msgCache) UserDeleteMsgs(ctx context.Context, conversationID string, se
// return errs.Wrap(err)
// }
//}
//_, err := pipe.Exec(ctx)
//return errs.Wrap(err)
// _, err := pipe.Exec(ctx)
// return errs.Wrap(err)
}
func (c *msgCache) GetUserDelList(ctx context.Context, userID, conversationID string) (seqs []int64, err error) {

View File

@ -44,7 +44,7 @@ func Test_BatchInsertChat2DB(t *testing.T) {
conf.RetainChatRecords = 3650
conf.ChatRecordsClearTime = "0 2 * * 3"
mongo, err := unrelation.NewMongo(conf)
mongo, err := unrelation.NewMongo(&conf.Mongo)
if err != nil {
t.Fatal(err)
}
@ -156,7 +156,7 @@ func GetDB() *commonMsgDatabase {
conf.RetainChatRecords = 3650
conf.ChatRecordsClearTime = "0 2 * * 3"
mongo, err := unrelation.NewMongo(conf)
mongo, err := unrelation.NewMongo(&conf.Mongo)
if err != nil {
panic(err)
}

View File

@ -34,7 +34,7 @@ type BlackModelInterface interface {
Create(ctx context.Context, blacks []*BlackModel) (err error)
Delete(ctx context.Context, blacks []*BlackModel) (err error)
// UpdateByMap(ctx context.Context, ownerUserID, blockUserID string, args map[string]any) (err error)
//Update(ctx context.Context, blacks []*BlackModel) (err error)
// Update(ctx context.Context, blacks []*BlackModel) (err error)
Find(ctx context.Context, blacks []*BlackModel) (blackList []*BlackModel, err error)
Take(ctx context.Context, ownerUserID, blockUserID string) (black *BlackModel, err error)
FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*BlackModel, err error)

View File

@ -48,7 +48,7 @@ type GroupMemberModelInterface interface {
SearchMember(ctx context.Context, keyword string, groupID string, pagination pagination.Pagination) (total int64, groupList []*GroupMemberModel, err error)
FindRoleLevelUserIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error)
// MapGroupMemberNum(ctx context.Context, groupIDs []string) (count map[string]uint32, err error)
//FindJoinUserID(ctx context.Context, groupIDs []string) (groupUsers map[string][]string, err error)
// FindJoinUserID(ctx context.Context, groupIDs []string) (groupUsers map[string][]string, err error)
FindUserJoinedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
TakeGroupMemberNum(ctx context.Context, groupID string) (count int64, err error)
// FindUsersJoinedGroupID(ctx context.Context, userIDs []string) (map[string][]string, error)

View File

@ -18,17 +18,17 @@ package unrelation
// "context"
//)
//
//const (
// const (
// CSuperGroup = "super_group"
// CUserToSuperGroup = "user_to_super_group"
//)
//
//type SuperGroupModel struct {
// type SuperGroupModel struct {
// GroupID string `bson:"group_id" json:"groupID"`
// MemberIDs []string `bson:"member_id_list" json:"memberIDList"`
//}
//
//func (SuperGroupModel) TableName() string {
// func (SuperGroupModel) TableName() string {
// return CSuperGroup
//}
//

View File

@ -27,19 +27,19 @@ package unrelation
// "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
//)
//
//func NewSuperGroupMongoDriver(database *mongo.Database) unrelation.SuperGroupModelInterface {
// func NewSuperGroupMongoDriver(database *mongo.Database) unrelation.SuperGroupModelInterface {
// return &SuperGroupMongoDriver{
// superGroupCollection: database.Collection(unrelation.CSuperGroup),
// userToSuperGroupCollection: database.Collection(unrelation.CUserToSuperGroup),
// }
//}
//
//type SuperGroupMongoDriver struct {
// type SuperGroupMongoDriver struct {
// superGroupCollection *mongo.Collection
// userToSuperGroupCollection *mongo.Collection
//}
//
//func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string) error {
// func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string) error {
// _, err := s.superGroupCollection.InsertOne(ctx, &unrelation.SuperGroupModel{
// GroupID: groupID,
// MemberIDs: initMemberIDs,