From 946dbc5efc0b1115efcdfefcf1d2c78e5a97c628 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 1 Sep 2022 21:15:30 +0800 Subject: [PATCH 1/3] change log file mode --- pkg/common/log/logrus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/log/logrus.go b/pkg/common/log/logrus.go index 2514de055..cee8316a2 100644 --- a/pkg/common/log/logrus.go +++ b/pkg/common/log/logrus.go @@ -36,7 +36,7 @@ func loggerInit(moduleName string) *Logger { logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel)) //Close std console output //os.O_WRONLY | os.O_CREATE | os.O_APPEND - src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_RDWR|os.O_CREATE, os.ModeAppend) + src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend) if err != nil { panic(err.Error()) } From 99ec0ed8df621e6e32b468e895718e6044c5e44f Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 1 Sep 2022 21:18:33 +0800 Subject: [PATCH 2/3] del key --- internal/rpc/cache/cache.go | 6 ++++-- pkg/common/db/rocks_cache/rocks_cache.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/rpc/cache/cache.go b/internal/rpc/cache/cache.go index 78bf8c124..117f3384c 100644 --- a/internal/rpc/cache/cache.go +++ b/internal/rpc/cache/cache.go @@ -3,16 +3,17 @@ package cache import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db/rocks_cache" + rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" pbCache "Open_IM/pkg/proto/cache" "Open_IM/pkg/utils" "context" - "google.golang.org/grpc" "net" "strconv" "strings" + + "google.golang.org/grpc" ) type cacheServer struct { @@ -67,6 +68,7 @@ func (s *cacheServer) Run() { log.NewError("0", "RegisterEtcd failed ", err.Error()) panic(utils.Wrap(err, "register cache module rpc to etcd err")) } + go rocksCache.DelKeys() err = srv.Serve(listener) if err != nil { log.NewError("0", "Serve failed ", err.Error()) diff --git a/pkg/common/db/rocks_cache/rocks_cache.go b/pkg/common/db/rocks_cache/rocks_cache.go index 1957b1e87..0f745c905 100644 --- a/pkg/common/db/rocks_cache/rocks_cache.go +++ b/pkg/common/db/rocks_cache/rocks_cache.go @@ -36,7 +36,7 @@ const ( conversationIDListCache = "CONVERSATION_ID_LIST_CACHE:" ) -func init() { +func DelKeys() { fmt.Println("init to del old keys") for _, key := range []string{groupCache, friendRelationCache, blackListCache, userInfoCache, groupInfoCache, groupOwnerIDCache, joinedGroupListCache, groupMemberInfoCache, groupAllMemberInfoCache, allFriendInfoCache} { From e990118475595b4180f9da442decede20bae5e6f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 1 Sep 2022 21:58:22 +0800 Subject: [PATCH 3/3] fix bug :pushMsg.MsgData.OfflinePushInfo==nil --- internal/push/logic/push_to_client.go | 7 +++++-- internal/rpc/group/group.go | 1 + .../im_mysql_model/group_member_model.go | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 2b8bbcfd8..d8e22836e 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -297,8 +297,11 @@ func GetOfflinePushOpts(pushMsg *pbPush.PushMsgReq) (opts push.PushOpts, err err log.NewDebug(pushMsg.OperationID, opts) } } - opts.IOSBadgeCount = pushMsg.MsgData.OfflinePushInfo.IOSBadgeCount - opts.IOSPushSound = pushMsg.MsgData.OfflinePushInfo.IOSPushSound + if pushMsg.MsgData.OfflinePushInfo != nil { + opts.IOSBadgeCount = pushMsg.MsgData.OfflinePushInfo.IOSBadgeCount + opts.IOSPushSound = pushMsg.MsgData.OfflinePushInfo.IOSPushSound + } + return opts, nil } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 7a821c34e..cf1033d4a 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -142,6 +142,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB) } } + if req.GroupInfo.GroupType != constant.SuperGroup { //to group member for _, user := range req.InitMemberList { diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go index 89526b9de..d73ee287d 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go @@ -34,6 +34,20 @@ func InsertIntoGroupMember(toInsertInfo db.GroupMember) error { return nil } +func BatchInsertIntoGroupMember(toInsertInfoList []*db.GroupMember) error { + //MessageList []*model_struct.LocalChatLog + //return utils.Wrap(d.conn.Create(MessageList).Error, "BatchInsertMessageList failed") + for _, toInsertInfo := range toInsertInfoList { + toInsertInfo.JoinTime = time.Now() + if toInsertInfo.RoleLevel == 0 { + toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers + } + toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) + } + return db.DB.MysqlDB.DefaultGormDB().Create(toInsertInfoList).Error + +} + func GetGroupMemberListByUserID(userID string) ([]db.GroupMember, error) { var groupMemberList []db.GroupMember err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error