commit a455d7d62bd058363c3ec506dfb24b53545494ea
parent beba7d3038c0693b37db325069d7693c92dc9118
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Sat, 26 Sep 2020 14:03:10 +0300
blacklist index fix
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/ii/db.go b/ii/db.go
@@ -191,8 +191,12 @@ func (db *DB) _CreateIndex() error {
return true
}
repto, _ := msg.Tag("repto")
+ ioff := off
+ if v, _ := msg.Tag("access"); v == "blacklist" {
+ ioff = -1
+ }
fidx.WriteString(fmt.Sprintf("%s:%s:%d:%s:%s:%s\n",
- msg.MsgId, msg.Echo, off, msg.To, msg.From, repto))
+ msg.MsgId, msg.Echo, ioff, msg.To, msg.From, repto))
off += int64(len(line) + 1)
return true
})
@@ -478,7 +482,11 @@ func prependStr(x []string, y string) []string {
// Default match function for queries.
func (db *DB) Match(info MsgInfo, r Query) bool {
if r.Blacklisted {
- return info.Off < 0
+ if info.Off >= 0 {
+ return false
+ }
+ } else if info.Off < 0 {
+ return false
}
if r.Echo != "" && r.Echo != info.Echo {
return false