Browse Source

Smarter SQL request to prevent spammers in public blogs

pull/277/head
Timothée Jaussoin 9 years ago
parent
commit
2726cfe2b4
  1. 51
      app/models/postn/PostnDAO.php

51
app/models/postn/PostnDAO.php

@ -697,19 +697,44 @@ class PostnDAO extends SQL {
function getLastBlogPublic($limitf = false, $limitr = false)
{
$this->_sql = '
select * from postn
left outer join contact on postn.aid = contact.jid
where
node = \'urn:xmpp:microblog:0\'
and postn.origin not in (select jid from rosterlink where session = :origin)
and postn.open = true
and content != \'\'
order by published desc
';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
switch($this->_dbtype) {
case 'mysql':
$this->_sql = '
select * from postn
left outer join contact on postn.aid = contact.jid
where
node = \'urn:xmpp:microblog:0\'
and postn.origin not in (select jid from rosterlink where session = :origin)
and postn.open = true
and content != \'\'
group by origin
order by published desc
';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
break;
case 'pgsql':
$this->_sql = '
select * from (
select distinct on (origin) * from postn
left outer join contact on postn.aid = contact.jid
where
node = \'urn:xmpp:microblog:0\'
and postn.origin not in (select jid from rosterlink where session = :origin)
and postn.open = true
and content != \'\'
';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
$this->_sql .= '
) p
order by published desc
';
break;
}
$this->prepare(
'Postn',

Loading…
Cancel
Save