Archived
1
0

make it work

This commit is contained in:
Jeff Becker 2017-09-23 09:58:29 -04:00
parent d2887a99b4
commit b61012fc43
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 5 additions and 6 deletions

View File

@ -866,7 +866,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er
// set message // set message
nntp.message = nntpSanitize(pr.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 { if err != nil {
e(err) e(err)
return return

View File

@ -1921,15 +1921,14 @@ func (self *PostgresDatabase) GetNewsgroupList() (list NewsgroupList, err error)
func (self *PostgresDatabase) FindCitesInText(text string) (msgids []string, err error) { func (self *PostgresDatabase) FindCitesInText(text string) (msgids []string, err error) {
hashes := findBacklinks(text) hashes := findBacklinks(text)
if len(hashes) > 0 { 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 params []string
var qparams []interface{} var qparams []interface{}
for idx := range hashes { for idx := range hashes {
params = append(params, fmt.Sprintf("$%d", idx+1)) params = append(params, fmt.Sprintf(" message_id_hash ILIKE $%d", idx+1))
qparams = append(qparams, hashes[idx]) qparams = append(qparams, strings.Trim(hashes[idx][2:], " ")+"%")
} }
q += strings.Join(params, ", ") q += strings.Join(params, " OR ")
q += " )"
var rows *sql.Rows var rows *sql.Rows
rows, err = self.conn.Query(q, qparams...) rows, err = self.conn.Query(q, qparams...)
if err == sql.ErrNoRows { if err == sql.ErrNoRows {