-
Notifications
You must be signed in to change notification settings - Fork 0
/
listen.go
36 lines (30 loc) · 776 Bytes
/
listen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package config
import (
"context"
"fmt"
pbd "github.com/brotherlogic/discogs/proto"
pb "github.com/brotherlogic/gramophile/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var (
LISTEN_FIELD = "LastListenDate"
)
type listen struct{}
func (*listen) GetMoves(c *pb.GramophileConfig) []*pb.FolderMove {
return []*pb.FolderMove{}
}
func (*listen) Validate(ctx context.Context, fields []*pbd.Field, c *pb.GramophileConfig) error {
if c.GetListenConfig().GetMandate() != pb.Mandate_NONE {
found := false
for _, field := range fields {
if field.GetName() == LISTEN_FIELD {
found = true
}
}
if !found {
return status.Errorf(codes.FailedPrecondition, fmt.Sprintf("Add a field called '%v'", LISTEN_FIELD))
}
}
return nil
}