From b61012fc4324dbd57dab117d11ef765909e6dbb9 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 23 Sep 2017 09:58:29 -0400 Subject: [PATCH] make it work --- contrib/backends/srndv2/src/srnd/frontend_http.go | 2 +- contrib/backends/srndv2/src/srnd/postgres.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/frontend_http.go b/contrib/backends/srndv2/src/srnd/frontend_http.go index 4795e59..2572b50 100644 --- a/contrib/backends/srndv2/src/srnd/frontend_http.go +++ b/contrib/backends/srndv2/src/srnd/frontend_http.go @@ -866,7 +866,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er // set message nntp.message = nntpSanitize(pr.Message) - cites, err := self.daemon.database.FindCitesInText(nntp.message) + cites, err := self.daemon.database.FindCitesInText(pr.Message) if err != nil { e(err) return diff --git a/contrib/backends/srndv2/src/srnd/postgres.go b/contrib/backends/srndv2/src/srnd/postgres.go index 37436a6..c83b78f 100644 --- a/contrib/backends/srndv2/src/srnd/postgres.go +++ b/contrib/backends/srndv2/src/srnd/postgres.go @@ -1921,15 +1921,14 @@ func (self *PostgresDatabase) GetNewsgroupList() (list NewsgroupList, err error) func (self *PostgresDatabase) FindCitesInText(text string) (msgids []string, err error) { hashes := findBacklinks(text) if len(hashes) > 0 { - q := "SELECT message_id FROM Articles WHERE message_id_hash IN ( " + q := "SELECT message_id FROM Articles WHERE " var params []string var qparams []interface{} for idx := range hashes { - params = append(params, fmt.Sprintf("$%d", idx+1)) - qparams = append(qparams, hashes[idx]) + params = append(params, fmt.Sprintf(" message_id_hash ILIKE $%d", idx+1)) + qparams = append(qparams, strings.Trim(hashes[idx][2:], " ")+"%") } - q += strings.Join(params, ", ") - q += " )" + q += strings.Join(params, " OR ") var rows *sql.Rows rows, err = self.conn.Query(q, qparams...) if err == sql.ErrNoRows {