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