mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
docker-compose fix
This commit is contained in:
parent
85f5c59781
commit
5afa3380a6
6
internal/rpc/cache/cache.go
vendored
6
internal/rpc/cache/cache.go
vendored
@ -94,7 +94,7 @@ func (s *cacheServer) GetFriendIDListFromCache(_ context.Context, req *pbCache.G
|
||||
// this is for dtm call
|
||||
func (s *cacheServer) DelFriendIDListFromCache(_ context.Context, req *pbCache.DelFriendIDListFromCacheReq) (resp *pbCache.DelFriendIDListFromCacheResp, err error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp = &pbCache.DelFriendIDListFromCacheResp{}
|
||||
resp = &pbCache.DelFriendIDListFromCacheResp{CommonResp: &pbCache.CommonResp{}}
|
||||
if err := rocksCache.DelFriendIDListFromCache(req.UserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "args: ", req.UserID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
@ -123,7 +123,7 @@ func (s *cacheServer) GetBlackIDListFromCache(_ context.Context, req *pbCache.Ge
|
||||
|
||||
func (s *cacheServer) DelBlackIDListFromCache(_ context.Context, req *pbCache.DelBlackIDListFromCacheReq) (resp *pbCache.DelBlackIDListFromCacheResp, err error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp = &pbCache.DelBlackIDListFromCacheResp{}
|
||||
resp = &pbCache.DelBlackIDListFromCacheResp{CommonResp: &pbCache.CommonResp{}}
|
||||
if err := rocksCache.DelBlackIDListFromCache(req.UserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "args: ", req.UserID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
@ -153,7 +153,7 @@ func (s *cacheServer) GetGroupMemberIDListFromCache(_ context.Context, req *pbCa
|
||||
|
||||
func (s *cacheServer) DelGroupMemberIDListFromCache(_ context.Context, req *pbCache.DelGroupMemberIDListFromCacheReq) (resp *pbCache.DelGroupMemberIDListFromCacheResp, err error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp = &pbCache.DelGroupMemberIDListFromCacheResp{}
|
||||
resp = &pbCache.DelGroupMemberIDListFromCacheResp{CommonResp: &pbCache.CommonResp{}}
|
||||
if err := rocksCache.DelGroupMemberIDListFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "args: ", req.GroupID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
|
@ -224,29 +224,53 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
for _, v := range joinedGroupList {
|
||||
var groupNode open_im_sdk.GroupInfo
|
||||
num, err := imdb.GetGroupMemberNumByGroupID(v)
|
||||
owner, err2 := imdb.GetGroupOwnerInfoByGroupID(v)
|
||||
group, err := rocksCache.GetGroupInfoFromCache(v)
|
||||
|
||||
log.NewInfo(req.OperationID, num, owner, err2, group, err)
|
||||
if num > 0 && owner != nil && err2 == nil && group != nil && err == nil {
|
||||
if group.Status == constant.GroupStatusDismissed {
|
||||
log.NewError(req.OperationID, "constant.GroupStatusDismissed ", group)
|
||||
continue
|
||||
}
|
||||
utils.CopyStructFields(&groupNode, group)
|
||||
groupNode.CreateTime = uint32(group.CreateTime.Unix())
|
||||
groupNode.NotificationUpdateTime = uint32(group.NotificationUpdateTime.Unix())
|
||||
if group.NotificationUpdateTime.Unix() < 0 {
|
||||
groupNode.NotificationUpdateTime = 0
|
||||
}
|
||||
|
||||
groupNode.MemberCount = uint32(num)
|
||||
groupNode.OwnerUserID = owner.UserID
|
||||
resp.GroupList = append(resp.GroupList, &groupNode)
|
||||
} else {
|
||||
log.NewError(req.OperationID, "check nil ", num, owner, err, group, err2)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v)
|
||||
continue
|
||||
}
|
||||
owner, err2 := imdb.GetGroupOwnerInfoByGroupID(v)
|
||||
if err2 != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err2.Error(), v)
|
||||
continue
|
||||
}
|
||||
group, err := rocksCache.GetGroupInfoFromCache(v)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v)
|
||||
continue
|
||||
}
|
||||
//if num > 0 && owner != nil && err2 == nil && group != nil && err == nil {
|
||||
// if group.Status == constant.GroupStatusDismissed {
|
||||
// log.NewError(req.OperationID, "constant.GroupStatusDismissed ", group)
|
||||
// continue
|
||||
// }
|
||||
// utils.CopyStructFields(&groupNode, group)
|
||||
// groupNode.CreateTime = uint32(group.CreateTime.Unix())
|
||||
// groupNode.NotificationUpdateTime = uint32(group.NotificationUpdateTime.Unix())
|
||||
// if group.NotificationUpdateTime.Unix() < 0 {
|
||||
// groupNode.NotificationUpdateTime = 0
|
||||
// }
|
||||
//
|
||||
// groupNode.MemberCount = uint32(num)
|
||||
// groupNode.OwnerUserID = owner.UserID
|
||||
// resp.GroupList = append(resp.GroupList, &groupNode)
|
||||
//} else {
|
||||
// log.NewError(req.OperationID, "check nil ", num, owner, err, group, err2)
|
||||
// continue
|
||||
//}
|
||||
if group.Status == constant.GroupStatusDismissed {
|
||||
log.NewError(req.OperationID, "constant.GroupStatusDismissed ", group)
|
||||
continue
|
||||
}
|
||||
utils.CopyStructFields(&groupNode, group)
|
||||
groupNode.CreateTime = uint32(group.CreateTime.Unix())
|
||||
groupNode.NotificationUpdateTime = uint32(group.NotificationUpdateTime.Unix())
|
||||
if group.NotificationUpdateTime.Unix() < 0 {
|
||||
groupNode.NotificationUpdateTime = 0
|
||||
}
|
||||
|
||||
groupNode.MemberCount = uint32(num)
|
||||
groupNode.OwnerUserID = owner.UserID
|
||||
resp.GroupList = append(resp.GroupList, &groupNode)
|
||||
log.NewDebug(req.OperationID, "joinedGroup ", groupNode)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList rpc return ", resp.String())
|
||||
|
@ -3,10 +3,10 @@ package rocksCache
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -57,10 +57,19 @@ func init() {
|
||||
func GetFriendIDListFromCache(userID string) ([]string, error) {
|
||||
getFriendIDList := func() (string, error) {
|
||||
friendIDList, err := imdb.GetFriendIDListByUserID(userID)
|
||||
return strings.Join(friendIDList, ","), err
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(friendIDList)
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
friendIDListStr, err := db.DB.Rc.Fetch(friendRelationCache+userID, time.Second*30*60, getFriendIDList)
|
||||
return strings.Split(friendIDListStr, ","), err
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var friendIDList []string
|
||||
err = json.Unmarshal([]byte(friendIDListStr), friendIDList)
|
||||
return friendIDList, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelFriendIDListFromCache(userID string) error {
|
||||
@ -71,10 +80,19 @@ func DelFriendIDListFromCache(userID string) error {
|
||||
func GetBlackListFromCache(userID string) ([]string, error) {
|
||||
getBlackIDList := func() (string, error) {
|
||||
blackIDList, err := imdb.GetBlackIDListByUserID(userID)
|
||||
return strings.Join(blackIDList, ","), err
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(blackIDList)
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
blackIDListStr, err := db.DB.Rc.Fetch(blackListCache+userID, time.Second*30*60, getBlackIDList)
|
||||
return strings.Split(blackIDListStr, ","), err
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var blackIDList []string
|
||||
err = json.Unmarshal([]byte(blackIDListStr), blackIDList)
|
||||
return blackIDList, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelBlackIDListFromCache(userID string) error {
|
||||
@ -84,10 +102,19 @@ func DelBlackIDListFromCache(userID string) error {
|
||||
func GetJoinedGroupIDListFromCache(userID string) ([]string, error) {
|
||||
getJoinedGroupIDList := func() (string, error) {
|
||||
joinedGroupList, err := imdb.GetJoinedGroupIDListByUserID(userID)
|
||||
return strings.Join(joinedGroupList, ","), err
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(joinedGroupList)
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
joinedGroupIDListStr, err := db.DB.Rc.Fetch(joinedGroupListCache+userID, time.Second*30*60, getJoinedGroupIDList)
|
||||
return strings.Split(joinedGroupIDListStr, ","), err
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var joinedGroupList []string
|
||||
err = json.Unmarshal([]byte(joinedGroupIDListStr), joinedGroupList)
|
||||
return joinedGroupList, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelJoinedGroupIDListFromCache(userID string) error {
|
||||
@ -98,12 +125,12 @@ func GetGroupOwnerFromCache(groupID string) (string, error) {
|
||||
getGroupOwnerIDList := func() (string, error) {
|
||||
groupOwner, err := imdb.GetGroupOwnerInfoByGroupID(groupID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
return groupOwner.UserID, err
|
||||
return groupOwner.UserID, utils.Wrap(err, "")
|
||||
}
|
||||
groupOwnerID, err := db.DB.Rc.Fetch(groupOwnerIDCache+groupID, time.Second*30*60, getGroupOwnerIDList)
|
||||
return groupOwnerID, err
|
||||
return groupOwnerID, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelGroupOwnerListFromCache(groupID string) error {
|
||||
@ -113,10 +140,19 @@ func DelGroupOwnerListFromCache(groupID string) error {
|
||||
func GetGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
||||
getGroupMemberIDList := func() (string, error) {
|
||||
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
|
||||
return strings.Join(groupMemberIDList, ","), err
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(groupMemberIDList)
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, getGroupMemberIDList)
|
||||
return strings.Split(groupIDListStr, ","), err
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var groupMemberIDList []string
|
||||
err = json.Unmarshal([]byte(groupIDListStr), groupMemberIDList)
|
||||
return groupMemberIDList, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelGroupMemberIDListFromCache(userID string) error {
|
||||
@ -128,18 +164,18 @@ func GetUserInfoFromCache(userID string) (*db.User, error) {
|
||||
getUserInfo := func() (string, error) {
|
||||
userInfo, err := imdb.GetUserByUserID(userID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(userInfo)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
userInfoStr, err := db.DB.Rc.Fetch(userInfoCache+userID, time.Second*30*60, getUserInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
userInfo := &db.User{}
|
||||
err = json.Unmarshal([]byte(userInfoStr), userInfo)
|
||||
return userInfo, err
|
||||
return userInfo, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelUserInfoFromCache(userID string) error {
|
||||
@ -150,18 +186,18 @@ func GetGroupMemberInfoFromCache(groupID, userID string) (*db.GroupMember, error
|
||||
getGroupMemberInfo := func() (string, error) {
|
||||
groupMemberInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(groupMemberInfo)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
groupMemberInfoStr, err := db.DB.Rc.Fetch(groupMemberInfoCache+groupID+"-"+userID, time.Second*30*60, getGroupMemberInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
groupMember := &db.GroupMember{}
|
||||
err = json.Unmarshal([]byte(groupMemberInfoStr), groupMember)
|
||||
return groupMember, err
|
||||
return groupMember, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelGroupMemberInfoFromCache(groupID, userID string) error {
|
||||
@ -172,18 +208,18 @@ func GetAllGroupMembersInfoFromCache(groupID string) ([]*db.GroupMember, error)
|
||||
getGroupMemberInfo := func() (string, error) {
|
||||
groupMembers, err := imdb.GetGroupMemberListByGroupID(groupID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(groupMembers)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
groupMembersStr, err := db.DB.Rc.Fetch(groupAllMemberInfoCache+groupID, time.Second*30*60, getGroupMemberInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var groupMembers []*db.GroupMember
|
||||
err = json.Unmarshal([]byte(groupMembersStr), &groupMembers)
|
||||
return groupMembers, err
|
||||
return groupMembers, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelAllGroupMembersInfoFromCache(groupID string) error {
|
||||
@ -194,18 +230,18 @@ func GetGroupInfoFromCache(groupID string) (*db.Group, error) {
|
||||
getGroupInfo := func() (string, error) {
|
||||
groupInfo, err := imdb.GetGroupInfoByGroupID(groupID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(groupInfo)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
groupInfoStr, err := db.DB.Rc.Fetch(groupInfoCache+groupID, time.Second*30*60, getGroupInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
groupInfo := &db.Group{}
|
||||
err = json.Unmarshal([]byte(groupInfoStr), groupInfo)
|
||||
return groupInfo, err
|
||||
return groupInfo, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelGroupInfoFromCache(groupID string) error {
|
||||
@ -216,18 +252,18 @@ func GetAllFriendsInfoFromCache(userID string) ([]*db.Friend, error) {
|
||||
getAllFriendInfo := func() (string, error) {
|
||||
friendInfoList, err := imdb.GetFriendListByUserID(userID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(friendInfoList)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
allFriendInfoStr, err := db.DB.Rc.Fetch(allFriendInfoCache+userID, time.Second*30*60, getAllFriendInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var friendInfoList []*db.Friend
|
||||
err = json.Unmarshal([]byte(allFriendInfoStr), &friendInfoList)
|
||||
return friendInfoList, err
|
||||
return friendInfoList, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelAllFriendsInfoFromCache(userID string) error {
|
||||
@ -238,18 +274,18 @@ func GetAllDepartmentsFromCache() ([]*db.Department, error) {
|
||||
getAllDepartments := func() (string, error) {
|
||||
departmentList, err := imdb.GetSubDepartmentList("-1")
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(departmentList)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
allDepartmentsStr, err := db.DB.Rc.Fetch(allDepartmentCache, time.Second*30*60, getAllDepartments)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var allDepartments []*db.Department
|
||||
err = json.Unmarshal([]byte(allDepartmentsStr), &allDepartments)
|
||||
return allDepartments, err
|
||||
return allDepartments, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelAllDepartmentsFromCache() error {
|
||||
@ -260,18 +296,18 @@ func GetAllDepartmentMembersFromCache() ([]*db.DepartmentMember, error) {
|
||||
getAllDepartmentMembers := func() (string, error) {
|
||||
departmentMembers, err := imdb.GetDepartmentMemberList("-1")
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", utils.Wrap(err, "")
|
||||
}
|
||||
bytes, err := json.Marshal(departmentMembers)
|
||||
return string(bytes), err
|
||||
return string(bytes), utils.Wrap(err, "")
|
||||
}
|
||||
allDepartmentMembersStr, err := db.DB.Rc.Fetch(allDepartmentMemberCache, time.Second*30*60, getAllDepartmentMembers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
var allDepartmentMembers []*db.DepartmentMember
|
||||
err = json.Unmarshal([]byte(allDepartmentMembersStr), &allDepartmentMembers)
|
||||
return allDepartmentMembers, err
|
||||
return allDepartmentMembers, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
func DelAllDepartmentMembersFromCache() error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user