Archived
1
0

add remove command for mod

This commit is contained in:
Jeff Becker 2018-11-27 10:45:21 -05:00
parent 053708a9cb
commit 0e6e2093e4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -47,7 +47,6 @@ type ModUI interface {
// handle mark a post as spam // handle mark a post as spam
HandlePostSpam(wr http.ResponseWriter, r *http.Request) HandlePostSpam(wr http.ResponseWriter, r *http.Request)
// get outbound message channel // get outbound message channel
MessageChan() chan NNTPMessage MessageChan() chan NNTPMessage
} }
@ -56,6 +55,7 @@ type ModAction string
const ModInetBan = ModAction("overchan-inet-ban") const ModInetBan = ModAction("overchan-inet-ban")
const ModDelete = ModAction("delete") const ModDelete = ModAction("delete")
const ModRemove = ModAction("remove")
const ModRemoveAttachment = ModAction("overchan-del-attachment") const ModRemoveAttachment = ModAction("overchan-del-attachment")
const ModStick = ModAction("overchan-stick") const ModStick = ModAction("overchan-stick")
const ModLock = ModAction("overchan-lock") const ModLock = ModAction("overchan-lock")
@ -437,7 +437,19 @@ func (mod *modEngine) Do(ev ModEvent) {
} else if action == ModSage { } else if action == ModSage {
// TODO: implement // TODO: implement
} else if action == ModStick { } else if action == ModStick {
// TODO: implement // TODP: implement
} else if action == ModRemove {
if ValidMessageID(target) {
err := mod.database.DeleteArticle(target)
if err == nil {
err = mod.store.Remove(target)
}
if err == nil {
log.Println("removed", target)
} else {
log.Println(action, target, "failed:", err)
}
}
} else if action == ModRemoveAttachment { } else if action == ModRemoveAttachment {
var delfiles []string var delfiles []string
atts := mod.database.GetPostAttachments(target) atts := mod.database.GetPostAttachments(target)