mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-15 09:47:09 +08:00
message
This commit is contained in:
parent
5e1aa43793
commit
84c7b8827e
@ -145,40 +145,6 @@ func DelJoinedGroupIDListFromCache(userID string) error {
|
|||||||
return db.DB.Rc.TagAsDeleted(joinedGroupListCache + userID)
|
return db.DB.Rc.TagAsDeleted(joinedGroupListCache + userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
|
||||||
f := func() (string, error) {
|
|
||||||
groupInfo, err := GetGroupInfoFromCache(groupID)
|
|
||||||
if err != nil {
|
|
||||||
return "", utils.Wrap(err, "GetGroupInfoFromCache failed")
|
|
||||||
}
|
|
||||||
var groupMemberIDList []string
|
|
||||||
if groupInfo.GroupType == constant.SuperGroup {
|
|
||||||
superGroup, err := db.DB.GetSuperGroup(groupID)
|
|
||||||
if err != nil {
|
|
||||||
return "", utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
groupMemberIDList = superGroup.MemberIDList
|
|
||||||
} else {
|
|
||||||
groupMemberIDList, err = imdb.GetGroupMemberIDListByGroupID(groupID)
|
|
||||||
if err != nil {
|
|
||||||
return "", utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bytes, err := json.Marshal(groupMemberIDList)
|
|
||||||
if err != nil {
|
|
||||||
return "", utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
return string(bytes), nil
|
|
||||||
}
|
|
||||||
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f)
|
|
||||||
if err != nil {
|
|
||||||
return nil, utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
var groupMemberIDList []string
|
|
||||||
err = json.Unmarshal([]byte(groupIDListStr), &groupMemberIDList)
|
|
||||||
return groupMemberIDList, utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func DelGroupMemberIDListFromCache(groupID string) error {
|
func DelGroupMemberIDListFromCache(groupID string) error {
|
||||||
err := db.DB.Rc.TagAsDeleted(groupCache + groupID)
|
err := db.DB.Rc.TagAsDeleted(groupCache + groupID)
|
||||||
return err
|
return err
|
||||||
@ -458,6 +424,39 @@ func GetGroupMemberListHashFromCache(groupID string) (uint64, error) {
|
|||||||
hashCodeUint64, err := strconv.Atoi(hashCode)
|
hashCodeUint64, err := strconv.Atoi(hashCode)
|
||||||
return uint64(hashCodeUint64), err
|
return uint64(hashCodeUint64), err
|
||||||
}
|
}
|
||||||
|
func GetGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
||||||
|
f := func() (string, error) {
|
||||||
|
groupInfo, err := GetGroupInfoFromCache(groupID)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "GetGroupInfoFromCache failed")
|
||||||
|
}
|
||||||
|
var groupMemberIDList []string
|
||||||
|
if groupInfo.GroupType == constant.SuperGroup {
|
||||||
|
superGroup, err := db.DB.GetSuperGroup(groupID)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
groupMemberIDList = superGroup.MemberIDList
|
||||||
|
} else {
|
||||||
|
groupMemberIDList, err = imdb.GetGroupMemberIDListByGroupID(groupID)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bytes, err := json.Marshal(groupMemberIDList)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
|
}
|
||||||
|
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f)
|
||||||
|
if err != nil {
|
||||||
|
return nil, utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
var groupMemberIDList []string
|
||||||
|
err = json.Unmarshal([]byte(groupIDListStr), &groupMemberIDList)
|
||||||
|
return groupMemberIDList, utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
|
||||||
func DelGroupMemberListHashFromCache(groupID string) error {
|
func DelGroupMemberListHashFromCache(groupID string) error {
|
||||||
err := db.DB.Rc.TagAsDeleted(groupMemberListHashCache + groupID)
|
err := db.DB.Rc.TagAsDeleted(groupMemberListHashCache + groupID)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user