mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-28 12:56:35 +08:00
friend db
This commit is contained in:
parent
22fa9dc0ba
commit
67e1faefd8
@ -2,13 +2,15 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
|
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -189,6 +191,7 @@ type config struct {
|
|||||||
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
||||||
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
||||||
ElasticSearchPassword string `yaml:"elasticSearchPassword"`
|
ElasticSearchPassword string `yaml:"elasticSearchPassword"`
|
||||||
|
isJson bool `yaml:"isJson"`
|
||||||
}
|
}
|
||||||
ModuleName struct {
|
ModuleName struct {
|
||||||
LongConnSvrName string `yaml:"longConnSvrName"`
|
LongConnSvrName string `yaml:"longConnSvrName"`
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/tx"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/tx"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tracelog"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tracelog"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
@ -73,7 +72,6 @@ func (f *friendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (
|
|||||||
func (f *friendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
|
func (f *friendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
|
||||||
return f.tx.Transaction(func(tx any) error {
|
return f.tx.Transaction(func(tx any) error {
|
||||||
_, err := f.friendRequest.NewTx(tx).Take(ctx, fromUserID, toUserID)
|
_, err := f.friendRequest.NewTx(tx).Take(ctx, fromUserID, toUserID)
|
||||||
log.ZError(ctx, "fr error", err)
|
|
||||||
//有db错误
|
//有db错误
|
||||||
if err != nil && errors.Unwrap(err) != gorm.ErrRecordNotFound {
|
if err != nil && errors.Unwrap(err) != gorm.ErrRecordNotFound {
|
||||||
return err
|
return err
|
||||||
|
@ -43,14 +43,14 @@ func (f *FriendRequestGorm) Update(ctx context.Context, friendRequests []*relati
|
|||||||
// 获取来指定用户的好友申请 未找到 不返回错误
|
// 获取来指定用户的好友申请 未找到 不返回错误
|
||||||
func (f *FriendRequestGorm) Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *relation.FriendRequestModel, err error) {
|
func (f *FriendRequestGorm) Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *relation.FriendRequestModel, err error) {
|
||||||
friendRequest = &relation.FriendRequestModel{}
|
friendRequest = &relation.FriendRequestModel{}
|
||||||
utils.Wrap(f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Find(friendRequest).Error, "")
|
err = utils.Wrap(f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Find(friendRequest).Error, "")
|
||||||
return
|
return friendRequest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *relation.FriendRequestModel, err error) {
|
func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *relation.FriendRequestModel, err error) {
|
||||||
friendRequest = &relation.FriendRequestModel{}
|
friendRequest = &relation.FriendRequestModel{}
|
||||||
utils.Wrap(f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Take(friendRequest).Error, "")
|
err = utils.Wrap(f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Take(friendRequest).Error, "")
|
||||||
return
|
return friendRequest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取toUserID收到的好友申请列表
|
// 获取toUserID收到的好友申请列表
|
||||||
|
Loading…
x
Reference in New Issue
Block a user