fix feed policy logic
This commit is contained in:
		@@ -4,8 +4,8 @@
 | 
				
			|||||||
package srnd
 | 
					package srnd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"log"
 | 
					 | 
				
			||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type FeedPolicy struct {
 | 
					type FeedPolicy struct {
 | 
				
			||||||
@@ -15,18 +15,22 @@ type FeedPolicy struct {
 | 
				
			|||||||
// do we allow this newsgroup?
 | 
					// do we allow this newsgroup?
 | 
				
			||||||
func (self *FeedPolicy) AllowsNewsgroup(newsgroup string) (result bool) {
 | 
					func (self *FeedPolicy) AllowsNewsgroup(newsgroup string) (result bool) {
 | 
				
			||||||
	var k, v string
 | 
						var k, v string
 | 
				
			||||||
 | 
						var allows, disallows int
 | 
				
			||||||
	for k, v = range self.rules {
 | 
						for k, v = range self.rules {
 | 
				
			||||||
 | 
							v = strings.Trim(v, " ")
 | 
				
			||||||
		match, err := regexp.MatchString(k, newsgroup)
 | 
							match, err := regexp.MatchString(k, newsgroup)
 | 
				
			||||||
		if err != nil {
 | 
							if err == nil {
 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
			if match {
 | 
								if match {
 | 
				
			||||||
			if v == "0" {
 | 
									if v == "1" {
 | 
				
			||||||
				return false
 | 
										allows++
 | 
				
			||||||
			} else if v == "1" {
 | 
									} else if v == "0" {
 | 
				
			||||||
				result = true
 | 
										disallows++
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	return result
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						result = allows > 0 && disallows == 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user