Skip to content
Commits on Source (2)
......@@ -220,6 +220,11 @@ class blog implements Interfaces\Api
$blog->setMature(!!$_POST['mature']);
}
if (isset($_POST['nsfw'])) {
$nsfw = !is_array($_POST['nsfw']) ? json_decode($_POST['nsfw']) : $_POST['nsfw'];
$blog->setNsfw($nsfw);
}
if (isset($_POST['wire_threshold'])) {
$threshold = is_string($_POST['wire_threshold']) ? json_decode($_POST['wire_threshold']) : $_POST['wire_threshold'];
$blog->setWireThreshold($threshold);
......@@ -266,7 +271,7 @@ class blog implements Interfaces\Api
}
if ($blog->isMonetized()) {
if ($blog->isMature()) {
if ($blog->getNsfw() || $blog->isMature()) {
return Factory::response([
'status' => 'error',
'message' => 'Cannot monetize an explicit blog'
......@@ -283,7 +288,8 @@ class blog implements Interfaces\Api
}
}
if (isset($_POST['mature']) && $_POST['mature']) {
if ((isset($_POST['nsfw']) && $_POST['nsfw'])
|| (isset($_POST['mature']) && $_POST['mature'])) {
$user = Core\Session::getLoggedInUser();
if (!$user->getMatureContent()) {
......
......@@ -263,10 +263,10 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
$entity = Core\Media\Factory::build($clientType);
$container_guid = isset($data['container_guid']) && is_numeric($data['container_guid']) ? $data['container_guid'] : null;
$entity->patch([
'title' => isset($data['name']) ? $data['name'] : '',
'mature' => isset($data['mature']) && !!$data['mature'],
'nsfw' => !is_array($_POST['nsfw']) ? json_decode($_POST['nsfw']) : $_POST['nsfw'],
'batch_guid' => 0,
'access_id' => 0,
'owner_guid' => $user->guid,
......
......@@ -539,6 +539,7 @@ class newsfeed implements Interfaces\Api
$activity = new Activity();
$activity->setMature(isset($_POST['mature']) && !!$_POST['mature']);
$activity->setNsfw($_POST['nsfw'] ?? []);
$user = Core\Session::getLoggedInUser();
......
......@@ -502,6 +502,7 @@ class Blog extends RepositoryEntity
}
}
$this->nsfw = $array;
$this->markAsDirty('nsfw');
return $this;
}
......
......@@ -60,6 +60,7 @@ class CreateActivity
->setThumbnail($blog->getIconUrl())
->setFromEntity($blog)
->setMature($blog->isMature())
->setNsfw($blog->getNsfw())
->setOwner($owner->export())
->setWireThreshold($blog->getWireThreshold())
->setPaywall($blog->isPaywall());
......
......@@ -138,6 +138,7 @@ class Manager
}
$this->paywallReview->queue($blog);
$this->propagateProperties->from($blog);
}
return $saved;
......
......@@ -265,6 +265,7 @@ class Image extends File
'description' => null,
'license' => null,
'mature' => null,
'nsfw' => null,
'boost_rejection_reason' => null,
'hidden' => null,
'batch_guid' => null,
......@@ -283,6 +284,7 @@ class Image extends File
'access_id',
'container_guid',
'mature',
'nsfw',
'boost_rejection_reason',
'rating',
'time_sent',
......@@ -297,7 +299,8 @@ class Image extends File
$data[$field] = (int) $data[$field];
} elseif ($field == 'mature') {
$this->setFlag('mature', !!$data['mature']);
continue;
} elseif ($field == 'nsfw') {
$this->setNsfw($data['nsfw']);
}
$this->$field = $data[$field];
......@@ -344,6 +347,7 @@ class Image extends File
'src' => \elgg_get_site_url() . 'fs/v1/thumbnail/' . $this->guid,
'href' => \elgg_get_site_url() . 'media/' . ($this->container_guid ? $this->container_guid . '/' : '') . $this->guid,
'mature' => $this->getFlag('mature'),
'nsfw' => $this->nsfw ?: [],
'width' => $this->width ?? 0,
'height' => $this->height ?? 0,
'gif' => (bool) ($this->gif ?? false),
......
......@@ -188,6 +188,7 @@ class Video extends MindsObject
'description' => null,
'license' => null,
'mature' => null,
'nsfw' => null,
'boost_rejection_reason' => null,
'hidden' => null,
'access_id' => null,
......@@ -205,6 +206,7 @@ class Video extends MindsObject
'access_id',
'container_guid',
'mature',
'nsfw',
'boost_rejection_reason',
'rating',
'time_sent',
......
......@@ -55,11 +55,15 @@ class CreateActivitySpec extends ObjectBehavior
$blog->getIconUrl()
->shouldBeCalled()
->willReturn('http://phpspec/icon.spec.ext');
$blog->isMature()
->shouldBeCalled()
->willReturn(false);
$blog->getNsfw()
->shouldBeCalled()
->willReturn([]);
$blog->getWireThreshold()
->shouldBeCalled()
->willReturn(null);
......