Skip to content

Commit

Permalink
(feat): report & appeals
Browse files Browse the repository at this point in the history
  • Loading branch information
markharding committed Sep 21, 2017
1 parent 92efc59 commit 59ae90f
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 7 deletions.
21 changes: 16 additions & 5 deletions bin/compileTrending.php
Expand Up @@ -15,14 +15,21 @@
echo "Collecting trending users:: \n";

$prepared = new Core\Data\Neo4j\Prepared\Common();
$result= Core\Data\Client::build('Neo4j')->request($prepared->getTrendingUsers(0, 500));
$result= Core\Data\Client::build('Neo4j')->request($prepared->getTrendingUsers(0, 750));
$rows = $result->getRows();

$g = new GUID();
$guids = array();
foreach ($rows['user'] as $i => $user) {
$i = $g->migrate($i);
$guids[$i] = $user['guid'];
$i = -1;
foreach ($rows['user'] as $user) {
$user = Entities\Factory::build($user['guid']);

if ($user->getSpam() || $user->getDeleted()) {
continue;
}

$key = $g->migrate($i++);
$guids[$key] = $user['guid'];
}

echo count($guids);
Expand All @@ -38,7 +45,7 @@

echo "Collecting trending {$subtype}s:: \n";

$result= Core\Data\Client::build('Neo4j')->request($prepared->getTrendingObjects($subtype, 0, 500));
$result= Core\Data\Client::build('Neo4j')->request($prepared->getTrendingObjects($subtype, 0, 750));
$rows = $result->getRows();

$g = new GUID();
Expand All @@ -49,6 +56,10 @@
$owner = Entities\Factory::build($entity->owner_guid);
if($entity && $entity->getFlag('mature'))
continue;
if($entity && $entity->getFlag('spam'))
continue;
if($entity && $entity->getFlag('deleted'))
continue;
if($owner && $owner->getMatureContent())
continue;
$key = $g->migrate($i++);
Expand Down
2 changes: 1 addition & 1 deletion plugins/blog/api/v1/blog.php
Expand Up @@ -120,7 +120,7 @@ public function get($pages)
$guid = (new \GUID())->migrate($guid);
}
$blog = new entities\Blog($guid);
if (!$blog->title && !$blog->description) {
if (!$blog->title && !$blog->description || Helpers\Flags::shouldFail($blog)) {
break;
}
$blog->fullExport = true;
Expand Down
9 changes: 9 additions & 0 deletions plugins/blog/app/view/view.html
@@ -1,3 +1,12 @@
<div class="m--spam-notice mdl-shadow--8dp" *ngIf="blog?.spam || blog?.deleted">
<ng-container *ngIf="blog?.spam">This blog was flagged as spam.</ng-container>
<ng-container *ngIf="blog?.deleted">This blog was flagged as deleted.</ng-container>

<ng-container *ngIf="!session.isAdmin()">
If you wish to appeal, please check your <a routerLink="/settings/reported-content">Reported Content console</a>.
</ng-container>
</div>

<header *ngIf="blog"
[ngClass]="{ 'm-mature-content': attachment.shouldBeBlurred(blog), 'm-mature-content-shown': attachment.isForcefullyShown(blog) }"
>
Expand Down
72 changes: 72 additions & 0 deletions plugins/blog/entities/Blog.php
Expand Up @@ -6,6 +6,8 @@

class Blog extends \ElggObject
{
protected $dirtyIndexes = false;

/**
* Set subtype to blog.
*/
Expand All @@ -16,6 +18,8 @@ protected function initializeAttributes()
$this->attributes['subtype'] = "blog";
$this->attributes['mature'] = false;
$this->attributes['boost_rejection_reason'] = -1;
$this->attributes['spam'] = false;
$this->attributes['deleted'] = false;
}

/**
Expand Down Expand Up @@ -97,6 +101,45 @@ public function getBoostRejectionReason()
return (int) $this->boost_rejection_reason;
}

/**
* Sets the spam flag for this blog
* @param mixed $value
*/
public function setSpam($value)
{
$this->spam = (bool) $value;
return $this;
}

/**
* Gets the spam flag
* @return boolean
*/
public function getSpam()
{
return (bool) $this->spam;
}

/**
* Sets the deleted flag for this blog
* @param mixed $value
*/
public function setDeleted($value)
{
$this->deleted = (bool) $value;
$this->dirtyIndexes = true;
return $this;
}

/**
* Gets the deleted flag
* @return boolean
*/
public function getDeleted()
{
return (bool) $this->deleted;
}

/**
* Return the url for this entity
*/
Expand All @@ -105,6 +148,29 @@ public function getUrl()
return elgg_get_site_url() . 'blog/view/' . $this->guid;
}

public function save($index = true)
{
if ($this->getDeleted()) {
$index = false;

if ($this->dirtyIndexes) {
$indexes = $this->getIndexKeys(true);

$db = new Core\Data\Call('entities_by_time');
foreach ($indexes as $idx) {
$db->removeAttributes($idx, [$this->guid]);
}
}
} else {
if ($this->dirtyIndexes) {
// Re-add to indexes, force as true
$index = true;
}
}

return parent::save($index);
}

public function export()
{
$export = parent::export();
Expand All @@ -116,6 +182,12 @@ public function export()
$export['mature'] = (bool) $export['mature'];
$export['boost_rejection_reason'] = $this->getBoostRejectionReason();
$export['monetized'] = (bool) $export['monetized'];

if (Helpers\Flags::shouldDiscloseStatus($this)) {
$export['spam'] = $this->getSpam();
$export['deleted'] = $this->getDeleted();
}

return $export;
}
}
3 changes: 2 additions & 1 deletion plugins/blog/start.php
Expand Up @@ -8,6 +8,7 @@
use Minds\Components;
use Minds\Core;
use Minds\Api;
use Minds\Helpers;

class start extends Components\Plugin
{
Expand All @@ -22,7 +23,7 @@ public function __construct()
$guid = (new \GUID())->migrate($guid);
}
$blog = new entities\Blog($guid);
if (!$blog->title) {
if (!$blog->title || Helpers\Flags::shouldFail($blog)) {
header("HTTP/1.0 404 Not Found");
return [
'robots' => 'noindex'
Expand Down

0 comments on commit 59ae90f

Please sign in to comment.