40 lines
790 B
Go
40 lines
790 B
Go
package moderation
|
|
|
|
import (
|
|
"context"
|
|
|
|
pb "tailly_clips/internal/moderation/proto"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type ModerationClient struct {
|
|
conn *grpc.ClientConn
|
|
client pb.ModerationServiceClient
|
|
}
|
|
|
|
func NewModerationClient(addr string) (*ModerationClient, error) {
|
|
conn, err := grpc.Dial(addr, grpc.WithInsecure())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &ModerationClient{
|
|
conn: conn,
|
|
client: pb.NewModerationServiceClient(conn),
|
|
}, nil
|
|
}
|
|
|
|
func (c *ModerationClient) Close() {
|
|
c.conn.Close()
|
|
}
|
|
func (c *ModerationClient) CheckVideoUrl(ctx context.Context, videoUrl string) (bool, error) {
|
|
resp, err := c.client.CheckVideo(ctx, &pb.VideoRequest{
|
|
VideoUrl: videoUrl,
|
|
})
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return resp.OverallDecision == "allowed", nil
|
|
}
|