You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/common/db/controller/black.go

103 lines
3.9 KiB

// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package controller
import (
"context"
feat: Remove MySQL and implement it all with Mongo (#1508) * fix: GetUserReqApplicationList error when there is a disbanded group chat * fix: error when querying some information about disbanded group * fix: GetUserReqApplicationList dismissed group error * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * merge * cicd: robot automated Change * sdkws.MsgData * user * interface{} -> any * user * third * group * group * group * group * group * group * conversation * standalone mysql db model * tx * s3 * group * mongo * group * group * group * group * group * group * refactor: add openim mysql to mongo refactor Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * refactor: add openim mysql to mongo refactor Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * remove mysql * remove mysql * friend * friend * friend * friend * friend * friend * group * convert * index * index * all * all * mysql2mongo * data conversion * up35 * up35 * feat: add format set Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix scripts Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * merge main * merge main * Update init-config.sh * fix: user args check --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <withchao@users.noreply.github.com> Co-authored-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: Xinwei Xiong <3293172751@qq.com>
9 months ago
"github.com/OpenIMSDK/tools/pagination"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils"
refactor: change project module name. (#1038) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: start don't kill old process Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: check component Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: pull message set isRead only message come from single. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: add ex field to update group info. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change * cicd: robot automated Change * refactor: change project module name. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: change project module name. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: change project module name. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer <FGadvancer@users.noreply.github.com>
1 year ago
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
)
type BlackDatabase interface {
// Create 增加黑名单
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
// Delete 删除黑名单
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
// FindOwnerBlacks 获取黑名单列表
feat: Remove MySQL and implement it all with Mongo (#1508) * fix: GetUserReqApplicationList error when there is a disbanded group chat * fix: error when querying some information about disbanded group * fix: GetUserReqApplicationList dismissed group error * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * merge * cicd: robot automated Change * sdkws.MsgData * user * interface{} -> any * user * third * group * group * group * group * group * group * conversation * standalone mysql db model * tx * s3 * group * mongo * group * group * group * group * group * group * refactor: add openim mysql to mongo refactor Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * refactor: add openim mysql to mongo refactor Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * remove mysql * remove mysql * friend * friend * friend * friend * friend * friend * group * convert * index * index * all * all * mysql2mongo * data conversion * up35 * up35 * feat: add format set Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix scripts Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * merge main * merge main * Update init-config.sh * fix: user args check --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <withchao@users.noreply.github.com> Co-authored-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: Xinwei Xiong <3293172751@qq.com>
9 months ago
FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*relation.BlackModel, err error)
add GetSpecifiedFriendsInfo (#986) * fix: create group type limit * fix: group notification * fix: group notification * fix: group notification * chore: group member hash * chore: group member hash * chore: group member hash * chore: group member hash * test: log * test: log * test: log * test: log * test: log * sync: hash code * sync: hash code * sync: hash code * test: log * test: log * test: log * test: log * test: log * fix: time stamp * fix: minio sign endpoint opts * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: minio bucket url * fix: op user info * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Conversation * fix: importFriends Notification * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Notification * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * TransferGroupOwner del group hash * add GetSpecifiedFriendsInfo * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <withchao@users.noreply.github.com>
1 year ago
FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error)
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
}
type blackDatabase struct {
black relation.BlackModelInterface
cache cache.BlackCache
}
func NewBlackDatabase(black relation.BlackModelInterface, cache cache.BlackCache) BlackDatabase {
return &blackDatabase{black, cache}
}
// Create 增加黑名单.
func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
if err := b.black.Create(ctx, blacks); err != nil {
return err
}
return b.deleteBlackIDsCache(ctx, blacks)
}
// Delete 删除黑名单.
func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
if err := b.black.Delete(ctx, blacks); err != nil {
return err
}
return b.deleteBlackIDsCache(ctx, blacks)
}
func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relation.BlackModel) (err error) {
cache := b.cache.NewCache()
for _, black := range blacks {
cache = cache.DelBlackIDs(ctx, black.OwnerUserID)
}
return cache.ExecDel(ctx)
}
// FindOwnerBlacks 获取黑名单列表.
feat: Remove MySQL and implement it all with Mongo (#1508) * fix: GetUserReqApplicationList error when there is a disbanded group chat * fix: error when querying some information about disbanded group * fix: GetUserReqApplicationList dismissed group error * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * fix: the original message referenced by the pull message processing is withdrawn * merge * cicd: robot automated Change * sdkws.MsgData * user * interface{} -> any * user * third * group * group * group * group * group * group * conversation * standalone mysql db model * tx * s3 * group * mongo * group * group * group * group * group * group * refactor: add openim mysql to mongo refactor Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * refactor: add openim mysql to mongo refactor Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * remove mysql * remove mysql * friend * friend * friend * friend * friend * friend * group * convert * index * index * all * all * mysql2mongo * data conversion * up35 * up35 * feat: add format set Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix scripts Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * merge main * merge main * Update init-config.sh * fix: user args check --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <withchao@users.noreply.github.com> Co-authored-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: Xinwei Xiong <3293172751@qq.com>
9 months ago
func (b *blackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*relation.BlackModel, err error) {
return b.black.FindOwnerBlacks(ctx, ownerUserID, pagination)
}
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true).
func (b *blackDatabase) CheckIn(
ctx context.Context,
userID1, userID2 string,
) (inUser1Blacks bool, inUser2Blacks bool, err error) {
userID1BlackIDs, err := b.cache.GetBlackIDs(ctx, userID1)
if err != nil {
return
}
userID2BlackIDs, err := b.cache.GetBlackIDs(ctx, userID2)
if err != nil {
return
}
log.ZDebug(ctx, "blackIDs", "user1BlackIDs", userID1BlackIDs, "user2BlackIDs", userID2BlackIDs)
return utils.IsContain(userID2, userID1BlackIDs), utils.IsContain(userID1, userID2BlackIDs), nil
}
func (b *blackDatabase) FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error) {
return b.cache.GetBlackIDs(ctx, ownerUserID)
}
add GetSpecifiedFriendsInfo (#986) * fix: create group type limit * fix: group notification * fix: group notification * fix: group notification * chore: group member hash * chore: group member hash * chore: group member hash * chore: group member hash * test: log * test: log * test: log * test: log * test: log * sync: hash code * sync: hash code * sync: hash code * test: log * test: log * test: log * test: log * test: log * fix: time stamp * fix: minio sign endpoint opts * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: minio bucket url * fix: op user info * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Conversation * fix: importFriends Notification * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Notification * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * TransferGroupOwner del group hash * add GetSpecifiedFriendsInfo * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <withchao@users.noreply.github.com>
1 year ago
func (b *blackDatabase) FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error) {
return b.black.FindOwnerBlackInfos(ctx, ownerUserID, userIDs)
}