Commit ddc2e70d authored by Mark Harding's avatar Mark Harding

(fix): apply channel tags to all entities

parent 8a53cac1
No related merge requests found
Pipeline #64120334 passed with stages
in 9 minutes and 43 seconds
......@@ -11,6 +11,7 @@ use Minds\Helpers;
use Minds\Helpers\Counters;
use Minds\Interfaces;
use Minds\Interfaces\Flaggable;
use Minds\Core\Entities\Actions\Save;
class remind implements Interfaces\Api
{
......@@ -59,6 +60,7 @@ class remind implements Interfaces\Api
}
}*/
$save = new Save();
$activity = new Activity();
$activity->setNSFW($embedded->getNSFW());
......@@ -74,7 +76,7 @@ class remind implements Interfaces\Api
} else {
$activity->setRemind($embedded->export())->save();
}
$activity->save();
$save->setEntity($activity)->save();
break;
default:
/**
......@@ -89,8 +91,8 @@ class remind implements Interfaces\Api
->setURL($embedded->getURL())
->setThumbnail($embedded->getIconUrl())
->setFromEntity($embedded)
->setMessage($message)
->save();
->setMessage($message);
$save->setEntity($activity)->save();
} else {
$activity->setRemind((new Activity())
->setTimeCreated($embedded->getTimeCreated())
......@@ -100,8 +102,8 @@ class remind implements Interfaces\Api
->setThumbnail($embedded->getIconUrl())
->setFromEntity($embedded)
->export())
->setMessage($message)
->save();
->setMessage($message);
$save->setEntity($activity)->save();
}
break;
case 'video':
......@@ -114,8 +116,8 @@ class remind implements Interfaces\Api
])
->setTitle($embedded->title)
->setBlurb($embedded->description)
->setMessage($message)
->save();
->setMessage($message);
$save->setEntity($activity)->save();
} else {
$activity = new Activity();
$activity->setRemind(
......@@ -132,8 +134,8 @@ class remind implements Interfaces\Api
->setBlurb($embedded->description)
->export()
)
->setMessage($message)
->save();
->setMessage($message);
$save->setEntity($activity)->save();
}
break;
case 'image':
......@@ -150,8 +152,8 @@ class remind implements Interfaces\Api
->setFromEntity($embedded)
->setTitle($embedded->title)
->setBlurb($embedded->description)
->setMessage($message)
->save();
->setMessage($message);
$save->setEntity($activity)->save();
} else {
$activity->setRemind(
(new Activity())
......@@ -171,8 +173,8 @@ class remind implements Interfaces\Api
->setBlurb($embedded->description)
->export()
)
->setMessage($message)
->save();
->setMessage($message);
$save->setEntity($activity)->save();
}
break;
}
......
......@@ -10,6 +10,7 @@ namespace Minds\Core\Entities\Actions;
use Minds\Core\Di\Di;
use Minds\Core\Events\Dispatcher;
use Minds\Helpers\MagicAttributes;
class Save
{
......@@ -96,12 +97,22 @@ class Save
if (method_exists($this->entity, 'getOwnerEntity') && $this->entity->getOwnerEntity()) {
$nsfwReasons = array_merge($nsfwReasons, $this->entity->getOwnerEntity()->getNSFW());
$nsfwReasons = array_merge($nsfwReasons, $this->entity->getOwnerEntity()->getNSFWLock());
// Legacy explicit follow through
if ($this->entity->getOwnerEntity()->isMature()) {
$nsfwReasons = array_merge($nsfwReasons, [ 6 ]);
if (MagicAttributes::setterExists($this->entity, 'setMature')) {
$this->entity->setMature(true);
} elseif (method_exists($this->entity, 'setFlag')) {
$this->entity->setFlag('mature', true);
}
}
}
if (method_exists($this->entity, 'getContainerEntity') && $this->entity->getContainerEntity()) {
$nsfwReasons = array_merge($nsfwReasons, $this->entity->getContainerEntity()->getNSFW());
$nsfwReasons = array_merge($nsfwReasons, $this->entity->getContainerEntity()->getNSFWLock());
}
$this->entity->setNSFW($nsfwReasons);
}
}
......@@ -90,6 +90,10 @@ class SaveSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn([]);
$owner->isMature()
->shouldBeCalled()
->willReturn(false);
$activity->getOwnerEntity()
->shouldBeCalled()
->willReturn($owner);
......@@ -128,6 +132,10 @@ class SaveSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn($nsfw);
$owner->isMature()
->shouldBeCalled()
->willReturn(false);
$activity->getOwnerEntity()
->shouldBeCalled()
->willReturn($owner);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment