Archived
1
0

remove fully

This commit is contained in:
Jeff Becker 2018-11-27 10:57:24 -05:00
parent 28e8e95207
commit a9f8bf2f8c
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 22 additions and 12 deletions

View File

@ -49,7 +49,6 @@ func (self PostEntry) Count() int64 {
type PostEntryList []PostEntry
// stats about newsgroup postings
type NewsgroupStats struct {
PPD int64
@ -69,8 +68,6 @@ type NewsgroupListEntry [3]string
type NewsgroupList []NewsgroupListEntry
type Database interface {
Close()
CreateTables()
@ -247,6 +244,9 @@ type Database interface {
// delete an article from the database
DeleteArticle(msg_id string) error
// remove an article from the database
RemoveArticle(msg_id string) error
// detele the existance of a thread from the threads table, does NOT remove replies
DeleteThread(root_msg_id string) error

View File

@ -442,10 +442,11 @@ func (mod *modEngine) Do(ev ModEvent) {
// TODP: implement
} else if action == ModRemove {
if ValidMessageID(target) {
err := mod.database.DeleteArticle(target)
if err == nil {
err = mod.store.Remove(target)
err := mod.database.RemoveArticle(target)
if err != nil {
log.Println("failed to forget", target, "because:", err)
}
err = mod.store.Remove(target)
if err == nil {
log.Println("removed", target)
} else {

View File

@ -153,6 +153,7 @@ const GetYearlyPostHistory = "GetYearlyPostHistory"
const GetNewsgroupList = "GetNewsgroupList"
const CountUkko = "CountUkko"
const GetNewsgroupStats = "GetNewsgroupStats"
const RemoveArticle = "RemoveArticle"
func (self *PostgresDatabase) prepareStatements() {
self.stmt = map[string]string{
@ -226,6 +227,7 @@ func (self *PostgresDatabase) prepareStatements() {
GetCitesByPostHashLike: "SELECT message_id, message_ref_id FROM Articles WHERE message_id_hash LIKE $1",
GetYearlyPostHistory: "WITH times(endtime, begintime) AS ( SELECT CAST(EXTRACT(epoch from i) AS BIGINT) AS endtime, CAST(EXTRACT(epoch from i - interval '1 month') AS BIGINT) AS begintime FROM generate_series(now() - interval '10 year', now(), '1 month'::interval) i ) SELECT begintime, endtime, ( SELECT count(*) FROM ArticlePosts WHERE time_posted > begintime AND time_posted < endtime) FROM times",
CountUkko: "SELECT COUNT(message_id) FROM ArticlePosts WHERE newsgroup != 'ctl' AND ref_id = '' OR ref_id = message_id",
RemoveArticle: "DELETE FROM Articles WHERE message_id = $1",
}
}
@ -1245,6 +1247,14 @@ func (self *PostgresDatabase) DeleteArticle(msgid string) (err error) {
*/
_, err = self.conn.Exec(self.stmt[DeleteArticleV8], msgid)
return
}
func (self *PostgresDatabase) RemoveArticle(msgid string) (err error) {
_, err = self.conn.Exec(self.stmt[DeleteArticleV8], msgid)
if err == nil {
_, err = self.conn.Exec(self.stmt[RemoveArticle], msgid)
}
return
}
func (self *PostgresDatabase) GetThreadReplyPostModels(prefix, rootpost string, start, limit int) (repls []PostModel) {
@ -2067,7 +2077,6 @@ func (self *PostgresDatabase) GetNewsgroupStats() (stats []NewsgroupStats, err e
return
}
func (self *PostgresDatabase) FindHeaders(group, headername string, lo, hi int64) (hdr ArticleHeaders, err error) {
hdr = make(ArticleHeaders)
q := "SELECT header_value FROM nntpheaders WHERE header_name = $1 AND header_article_message_id IN ( SELECT message_id FROM articleposts WHERE newsgroup = $2 )"