mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
bcbade3729
@ -87,8 +87,8 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
|||||||
appID: 1302656840
|
appID: 1302656840
|
||||||
region: ap-chengdu
|
region: ap-chengdu
|
||||||
bucket: echat-1302656840
|
bucket: echat-1302656840
|
||||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
||||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
||||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||||
bucket: openim
|
bucket: openim
|
||||||
location: us-east-1
|
location: us-east-1
|
||||||
|
6
internal/rpc/cache/cache.go
vendored
6
internal/rpc/cache/cache.go
vendored
@ -118,7 +118,7 @@ func updateAllFriendToCache(userList []db.User) error {
|
|||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := db.DB.AddFriendToCache(user.UserID, friendIDList); err != nil {
|
if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ func updateAllBlackListToCache(userList []db.User) error {
|
|||||||
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList); err != nil {
|
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,6 +187,7 @@ func (s *cacheServer) GetFriendIDListFromCache(_ context.Context, req *pbCache.G
|
|||||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), friendIDList)
|
||||||
resp.UserIDList = friendIDList
|
resp.UserIDList = friendIDList
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -228,6 +229,7 @@ func (s *cacheServer) GetBlackIDListFromCache(_ context.Context, req *pbCache.Ge
|
|||||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), blackUserIDList)
|
||||||
resp.UserIDList = blackUserIDList
|
resp.UserIDList = blackUserIDList
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
@ -262,10 +262,10 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||||
client := pbCache.NewCacheClient(etcdConn)
|
client := pbCache.NewCacheClient(etcdConn)
|
||||||
addFriendToCacheReq.UserID = req.CommID.ToUserID
|
addFriendToCacheReq.UserID = req.CommID.ToUserID
|
||||||
addFriendToCacheReq.UserID = req.CommID.FromUserID
|
addFriendToCacheReq.FriendID = req.CommID.FromUserID
|
||||||
respPb, err := client.AddFriendToCache(context.Background(), addFriendToCacheReq)
|
respPb, err := client.AddFriendToCache(context.Background(), addFriendToCacheReq)
|
||||||
addFriendToCacheReq.UserID = req.CommID.FromUserID
|
addFriendToCacheReq.UserID = req.CommID.FromUserID
|
||||||
addFriendToCacheReq.UserID = req.CommID.ToUserID
|
addFriendToCacheReq.FriendID = req.CommID.ToUserID
|
||||||
respPb, err = client.AddFriendToCache(context.Background(), addFriendToCacheReq)
|
respPb, err = client.AddFriendToCache(context.Background(), addFriendToCacheReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.CommID.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error())
|
log.NewError(req.CommID.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error())
|
||||||
|
@ -450,6 +450,7 @@ func (s *officeServer) CommentOneWorkMoment(_ context.Context, req *pbOffice.Com
|
|||||||
Content: comment.Content,
|
Content: comment.Content,
|
||||||
CreateTime: comment.CreateTime,
|
CreateTime: comment.CreateTime,
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "msg: ", *workMomentNotificationMsg)
|
||||||
if req.UserID != workMoment.UserID {
|
if req.UserID != workMoment.UserID {
|
||||||
msg.WorkMomentSendNotification(req.OperationID, workMoment.UserID, workMomentNotificationMsg)
|
msg.WorkMomentSendNotification(req.OperationID, workMoment.UserID, workMomentNotificationMsg)
|
||||||
}
|
}
|
||||||
@ -510,16 +511,7 @@ func (s *officeServer) GetUserFriendWorkMoments(_ context.Context, req *pbOffice
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp = &pbOffice.GetUserFriendWorkMomentsResp{CommonResp: &pbOffice.CommonResp{}, WorkMoments: []*pbOffice.WorkMoment{}}
|
resp = &pbOffice.GetUserFriendWorkMomentsResp{CommonResp: &pbOffice.CommonResp{}, WorkMoments: []*pbOffice.WorkMoment{}}
|
||||||
resp.Pagination = &pbCommon.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}
|
resp.Pagination = &pbCommon.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}
|
||||||
friendIDList, err := imdb.GetFriendIDListByUserID(req.UserID)
|
workMoments, err := db.DB.GetUserFriendWorkMoments(req.Pagination.ShowNumber, req.Pagination.PageNumber, req.UserID)
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListByUserID", err.Error())
|
|
||||||
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
for _, friendID := range friendIDList {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), friendID)
|
|
||||||
}
|
|
||||||
workMoments, err := db.DB.GetUserFriendWorkMoments(friendIDList, req.Pagination.ShowNumber, req.Pagination.PageNumber, req.UserID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserFriendWorkMoments", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserFriendWorkMoments", err.Error())
|
||||||
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
@ -692,7 +692,7 @@ func (d *DataBases) GetUserWorkMoments(opUserID, userID string, showNumber, page
|
|||||||
return workMomentList, err
|
return workMomentList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetUserFriendWorkMoments(friendIDList []string, showNumber, pageNumber int32, userID string) ([]WorkMoment, error) {
|
func (d *DataBases) GetUserFriendWorkMoments(showNumber, pageNumber int32, userID string) ([]WorkMoment, error) {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
||||||
var workMomentList []WorkMoment
|
var workMomentList []WorkMoment
|
||||||
@ -700,7 +700,7 @@ func (d *DataBases) GetUserFriendWorkMoments(friendIDList []string, showNumber,
|
|||||||
result, err := c.Find(ctx, bson.D{
|
result, err := c.Find(ctx, bson.D{
|
||||||
{"$or", bson.A{
|
{"$or", bson.A{
|
||||||
bson.D{{"user_id", userID}}, //self
|
bson.D{{"user_id", userID}}, //self
|
||||||
bson.D{{"user_id", bson.D{{"$in", friendIDList}}},
|
bson.D{
|
||||||
{"$or", bson.A{
|
{"$or", bson.A{
|
||||||
bson.D{{"permission", constant.WorkMomentPermissionCantSee}, {"permission_user_id_list", bson.D{{"$nin", bson.A{userID}}}}},
|
bson.D{{"permission", constant.WorkMomentPermissionCantSee}, {"permission_user_id_list", bson.D{{"$nin", bson.A{userID}}}}},
|
||||||
bson.D{{"permission", constant.WorkMomentPermissionCanSee}, {"permission_user_id_list", bson.D{{"$in", bson.A{userID}}}}},
|
bson.D{{"permission", constant.WorkMomentPermissionCanSee}, {"permission_user_id_list", bson.D{{"$in", bson.A{userID}}}}},
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -182,32 +181,48 @@ func (d *DataBases) GetUserInfoFromCache(userID string) (*pbCommon.UserInfo, err
|
|||||||
return userInfo, err
|
return userInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) AddFriendToCache(userID string, friendIDList ...interface{}) error {
|
func (d *DataBases) AddFriendToCache(userID string, friendIDList ...string) error {
|
||||||
_, err := d.Exec("SADD", friendRelationCache+userID, friendIDList...)
|
var IDList []interface{}
|
||||||
|
for _, id := range friendIDList {
|
||||||
|
IDList = append(IDList, id)
|
||||||
|
}
|
||||||
|
_, err := d.Exec("SADD", friendRelationCache+userID, IDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...interface{}) error {
|
func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...string) error {
|
||||||
_, err := d.Exec("SREM", friendRelationCache+userID, friendIDList...)
|
var IDList []interface{}
|
||||||
|
for _, id := range friendIDList {
|
||||||
|
IDList = append(IDList, id)
|
||||||
|
}
|
||||||
|
_, err := d.Exec("SREM", friendRelationCache+userID, IDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) {
|
func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) {
|
||||||
result, err := redis.String(d.Exec("SMEMBERS", friendRelationCache+userID))
|
result, err := redis.Strings(d.Exec("SMEMBERS", friendRelationCache+userID))
|
||||||
return strings.Split(result, " "), err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) AddBlackUserToCache(userID string, blackList ...interface{}) error {
|
func (d *DataBases) AddBlackUserToCache(userID string, blackList ...string) error {
|
||||||
_, err := d.Exec("SADD", blackListCache+userID, blackList...)
|
var IDList []interface{}
|
||||||
|
for _, id := range blackList {
|
||||||
|
IDList = append(IDList, id)
|
||||||
|
}
|
||||||
|
_, err := d.Exec("SADD", blackListCache+userID, IDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...interface{}) error {
|
func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...string) error {
|
||||||
_, err := d.Exec("SREM", blackListCache+userID, blackList...)
|
var IDList []interface{}
|
||||||
|
for _, id := range blackList {
|
||||||
|
IDList = append(IDList, id)
|
||||||
|
}
|
||||||
|
_, err := d.Exec("SREM", blackListCache+userID, IDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) {
|
func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) {
|
||||||
result, err := redis.String(d.Exec("SMEMBERS", blackListCache+userID))
|
result, err := redis.Strings(d.Exec("SMEMBERS", blackListCache+userID))
|
||||||
return strings.Split(result, " "), err
|
return result, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user