Allow admins to set a time when creating a post via the API

Again, the use-case for this is to allow the API to be used to import data from an old forum.
This commit is contained in:
Toby Zerner 2016-01-02 15:25:48 +10:30
parent d19cd6fc75
commit 646ed873eb

View File

@ -10,6 +10,7 @@
namespace Flarum\Core\Command;
use DateTime;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Validator\PostValidator;
use Flarum\Event\PostWillBeSaved;
@ -85,6 +86,10 @@ class PostReplyHandler
$command->ipAddress
);
if ($actor->isAdmin() && ($time = array_get($command->data, 'attributes.time'))) {
$post->time = new DateTime($time);
}
$this->events->fire(
new PostWillBeSaved($post, $actor, $command->data)
);