Keep Twitter gateway notices from leaking thru MySQL notice search

This commit is contained in:
Zach Copley 2009-06-19 20:21:57 -07:00
parent f5b24133cb
commit b8f3f32f3f
1 changed files with 14 additions and 3 deletions

View File

@ -118,12 +118,20 @@ class MySQLSearch extends SearchEngine
}
return true;
} else if ('identica_notices' === $this->table) {
$this->target->whereAdd('MATCH(content) ' .
'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
// Don't show imported notices
$this->target->whereAdd('notice.is_local != ' . NOTICE_GATEWAY);
if (strtolower($q) != $q) {
$this->target->whereAdd("( MATCH(content) AGAINST ('" . addslashes($q) .
"' IN BOOLEAN MODE)) OR ( MATCH(content) " .
"AGAINST ('" . addslashes(strtolower($q)) .
"' IN BOOLEAN MODE))");
} else {
$this->target->whereAdd('MATCH(content) ' .
'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
}
return true;
} else {
throw new ServerException('Unknown table: ' . $this->table);
@ -138,6 +146,9 @@ class PGSearch extends SearchEngine
if ('identica_people' === $this->table) {
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
} else if ('identica_notices' === $this->table) {
// XXX: We need to filter out gateway notices (notice.is_local = -2) --Zach
return $this->target->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')');
} else {
throw new ServerException('Unknown table: ' . $this->table);