From 9e291b1c5a07181859573ec477cdfd83a43cb5a9 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 23 Apr 2017 07:53:56 -0400 Subject: [PATCH] fix feed policy logic --- contrib/backends/srndv2/src/srnd/policy.go | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/policy.go b/contrib/backends/srndv2/src/srnd/policy.go index f5cf783..1bbd2ad 100644 --- a/contrib/backends/srndv2/src/srnd/policy.go +++ b/contrib/backends/srndv2/src/srnd/policy.go @@ -4,8 +4,8 @@ package srnd import ( - "log" "regexp" + "strings" ) type FeedPolicy struct { @@ -15,18 +15,22 @@ type FeedPolicy struct { // do we allow this newsgroup? func (self *FeedPolicy) AllowsNewsgroup(newsgroup string) (result bool) { var k, v string + var allows, disallows int for k, v = range self.rules { + v = strings.Trim(v, " ") match, err := regexp.MatchString(k, newsgroup) - if err != nil { - log.Fatal(err) - } - if match { - if v == "0" { - return false - } else if v == "1" { - result = true + if err == nil { + if match { + if v == "1" { + allows++ + } else if v == "0" { + disallows++ + } } } } - return result + + result = allows > 0 && disallows == 0 + + return }