Optionally hide spam from timelines
For sites with a lot of spam, this will hide that spam from timelines for everyone but moderators.
This commit is contained in:
parent
a431fca442
commit
d942072a6c
|
@ -2387,9 +2387,11 @@ class Notice extends Managed_DataObject
|
|||
|
||||
// If there's no scope, anyone (even anon) is in scope.
|
||||
|
||||
if ($scope == 0) {
|
||||
return true;
|
||||
}
|
||||
if ($scope == 0) { // Not private
|
||||
|
||||
return !$this->isHiddenSpam();
|
||||
|
||||
} else { // Private, somehow
|
||||
|
||||
// If there's scope, anon cannot be in scope
|
||||
|
||||
|
@ -2448,15 +2450,39 @@ class Notice extends Managed_DataObject
|
|||
|
||||
// Only for followers of the author
|
||||
|
||||
$author = null;
|
||||
|
||||
if ($scope & Notice::FOLLOWER_SCOPE) {
|
||||
|
||||
$author = $this->getProfile();
|
||||
|
||||
if (!Subscription::exists($profile, $author)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !$this->isHiddenSpam();
|
||||
}
|
||||
}
|
||||
|
||||
function isHiddenSpam() {
|
||||
|
||||
|
||||
// Hide posts by silenced users from everyone but moderators.
|
||||
|
||||
if (common_config('notice', 'hidespam')) {
|
||||
|
||||
$author = $this->getProfile();
|
||||
|
||||
if ($author->hasRole(Profile_role::SILENCED)) {
|
||||
if (!$profile->hasRole(Profile_role::MODERATOR)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static function groupsFromText($text, $profile)
|
||||
{
|
||||
|
|
|
@ -288,7 +288,8 @@ $default =
|
|||
'gc_limit' => 1000), // max sessions to expire at a time
|
||||
'notice' =>
|
||||
array('contentlimit' => null,
|
||||
'defaultscope' => null), // null means 1 if site/private, 0 otherwise
|
||||
'defaultscope' => null, // null means 1 if site/private, 0 otherwise
|
||||
'hidespam' => false), // Whether to hide silenced users from timelines
|
||||
'message' =>
|
||||
array('contentlimit' => null),
|
||||
'location' =>
|
||||
|
|
|
@ -151,6 +151,20 @@ class NoticeList extends Widget
|
|||
Memcached_DataObject::pivotGet('Notice', 'repeat_of', $ids, array('profile_id' => $p->id));
|
||||
}
|
||||
|
||||
if (common_config('notice', 'hidespam')) {
|
||||
|
||||
$pids = array();
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
$pids[] = $profile->id;
|
||||
}
|
||||
|
||||
Memcached_DataObject::pivotGet('Profile_role',
|
||||
'profile_id',
|
||||
$pids,
|
||||
array('role' => Profile_role::SILENCED));
|
||||
}
|
||||
|
||||
Event::handle('EndNoticeListPrefill', array(&$notices, &$profiles, $avatarSize));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user