diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-06-19 20:21:57 -0700 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-06-19 20:21:57 -0700 |
commit | b8f3f32f3f12339c3838fcfc883815d63a36dca7 (patch) | |
tree | 7f9950ced778bf3ed39cbb7622e088ae69ee3dce | |
parent | f5b24133cb63b8fd8ec2a989b77bd075dd77367f (diff) |
Keep Twitter gateway notices from leaking thru MySQL notice search
-rw-r--r-- | lib/search_engines.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/search_engines.php b/lib/search_engines.php index 7b9dbb618..0f405afbd 100644 --- a/lib/search_engines.php +++ b/lib/search_engines.php @@ -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); |