mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 00:03:37 +08:00
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:
parent
d19cd6fc75
commit
646ed873eb
|
@ -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)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user