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

31 lines
893 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"
)
type BlackClient struct {
*MetaClient
}
func NewBlackClient(zk discoveryRegistry.SvcDiscoveryRegistry) *BlackClient {
return &BlackClient{NewMetaClient(zk, config.Config.RpcRegisterName.OpenImFriendName)}
}
// possibleBlackUserID是否被userID拉黑也就是是否在userID的黑名单中
func (b *BlackClient) IsBlocked(ctx context.Context, possibleBlackUserID, userID string) (bool, error) {
2 years ago
cc, err := b.getConn(ctx)
2 years ago
if err != nil {
return false, err
}
r, err := friend.NewFriendClient(cc).IsBlack(ctx, &friend.IsBlackReq{UserID1: possibleBlackUserID, UserID2: userID})
if err != nil {
return false, err
}
return r.InUser2Blacks, nil
}