luceos
I was not able to send a message via the REST API ? But I was able to emulate the environment to send over Flarum code. It is likely that something else can be simplified. The code is as follows:
require 'vendor/autoload.php';
class MyServer extends Flarum\Forum\Server
{
public function app()
{
return $this->getApp();
}
}
$server = new MyServer(__DIR__);
$app = $server->app();
$discussionId = 2;
$actorId = 2;
$actor = Flarum\Core\User::find($actorId);
$discussion = Flarum\Core\Discussion::find($discussionId);
$data = [
'attributes' => [
'content' => 'Hello world 2!',
'time' => Carbon\Carbon::now('utc')->toDateTimeString(),
],
];
$ipAddress = NULL;
$cmd = new Flarum\Core\Command\PostReply($discussionId, $actor, $data, $ipAddress);
$handler = new Flarum\Core\Command\PostReplyHandler(
$app->events,
new Flarum\Core\Repository\DiscussionRepository,
new Flarum\Core\Notification\NotificationSyncer(new Flarum\Core\Repository\NotificationRepository, new Flarum\Core\Notification\NotificationMailer($app->mailer)),
new Flarum\Core\Validator\PostValidator($app->validator, $app->events, $app->make('Symfony\Component\Translation\TranslatorInterface'))
);
$handler->handle($cmd);