Archived
1
0
This commit is contained in:
Jeff Becker 2019-01-29 06:57:08 -05:00
parent bcddab9af6
commit 59068bb961
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 18 additions and 23 deletions

View File

@ -198,8 +198,6 @@ type ModEngine interface {
AllowBan(pubkey string) bool
// allow janitor
AllowJanitor(pubkey string) bool
// load a mod message
LoadMessage(msgid string) NNTPMessage
// execute 1 mod action line by a mod with pubkey
Execute(ev ModEvent, pubkey string)
// do a mod event unconditionally
@ -227,10 +225,6 @@ func (self *modEngine) MarkSpam(msgid string) (err error) {
return
}
func (self *modEngine) LoadMessage(msgid string) NNTPMessage {
return self.store.GetMessage(msgid)
}
func (self *modEngine) BanAddress(cidr string) (err error) {
return self.database.BanAddr(cidr)
}
@ -345,7 +339,7 @@ func (self *modEngine) AllowDelete(pubkey, msgid string) (allow bool) {
}
func (mod *modEngine) HandleMessage(msgid string) {
nntp := mod.store.GetMessage(msgid)
mod.store.GetMessage(msgid, func(nntp NNTPMessage) {
if nntp == nil {
log.Println("failed to load", msgid, "in mod engine, missing message")
return
@ -361,6 +355,7 @@ func (mod *modEngine) HandleMessage(msgid string) {
}
}
}
})
}
func (mod *modEngine) Do(ev ModEvent) {

View File

@ -75,7 +75,7 @@ type ArticleStore interface {
// register signed message
RegisterSigned(msgid, pk string) error
GetMessage(msgid string) NNTPMessage
GetMessage(msgid string, visit func(NNTPMessage))
// get size of message on disk
GetMessageSize(msgid string) (int64, error)
@ -584,7 +584,7 @@ func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter
return
}
func (self *articleStore) GetMessage(msgid string) (nntp NNTPMessage) {
func (self *articleStore) GetMessage(msgid string, visit func(NNTPMessage)) {
r, err := self.OpenMessage(msgid)
if err == nil {
defer r.Close()
@ -597,7 +597,7 @@ func (self *articleStore) GetMessage(msgid string) (nntp NNTPMessage) {
// inject pubkey for mod
n.Headers().Set("X-PubKey-Ed25519", hdr.Get("X-PubKey-Ed25519"))
}
nntp = n
visit(n)
})
}
}