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/rpcclient/black.go

32 lines
947 B

2 years ago
package rpcclient
import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
1 year ago
"google.golang.org/grpc"
2 years ago
)
type BlackClient struct {
1 year ago
conn *grpc.ClientConn
2 years ago
}
1 year ago
func NewBlackClient(discov discoveryRegistry.SvcDiscoveryRegistry) *BlackClient {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
if err != nil {
panic(err)
}
return &BlackClient{conn: conn}
2 years ago
}
// possibleBlackUserID是否被userID拉黑也就是是否在userID的黑名单中
func (b *BlackClient) IsBlocked(ctx context.Context, possibleBlackUserID, userID string) (bool, error) {
1 year ago
r, err := friend.NewFriendClient(b.conn).IsBlack(ctx, &friend.IsBlackReq{UserID1: possibleBlackUserID, UserID2: userID})
2 years ago
if err != nil {
return false, err
}
return r.InUser2Blacks, nil
}