mirror of
https://github.com/flarum/core.git
synced 2025-08-24 09:03:05 +02:00
@@ -61,13 +61,14 @@ class CreateDiscussionController extends AbstractCreateController
|
||||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
$actor = $request->getAttribute('actor');
|
||||
$ipAddress = array_get($request->getServerParams(), 'REMOTE_ADDR', '127.0.0.1');
|
||||
|
||||
if (! $request->getAttribute('bypassFloodgate')) {
|
||||
$this->floodgate->assertNotFlooding($actor);
|
||||
}
|
||||
|
||||
$discussion = $this->bus->dispatch(
|
||||
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data', []))
|
||||
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data', []), $ipAddress)
|
||||
);
|
||||
|
||||
// After creating the discussion, we assume that the user has seen all
|
||||
|
@@ -47,6 +47,9 @@ class PostSerializer extends PostBasicSerializer
|
||||
if ($canEdit) {
|
||||
$attributes['content'] = $post->content;
|
||||
}
|
||||
if ($gate->allows('viewPostIps', $post)) {
|
||||
$attributes['ipAddress'] = $post->ip_address;
|
||||
}
|
||||
} else {
|
||||
$attributes['content'] = $post->content;
|
||||
}
|
||||
|
@@ -32,9 +32,10 @@ class StartDiscussion
|
||||
* @param User $actor The user authoring the discussion.
|
||||
* @param array $data The discussion attributes.
|
||||
*/
|
||||
public function __construct(User $actor, array $data)
|
||||
public function __construct(User $actor, array $data, $ipAddress)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->data = $data;
|
||||
$this->ipAddress = $ipAddress;
|
||||
}
|
||||
}
|
||||
|
@@ -55,6 +55,7 @@ class StartDiscussionHandler
|
||||
{
|
||||
$actor = $command->actor;
|
||||
$data = $command->data;
|
||||
$ipAddress = $command->ipAddress;
|
||||
|
||||
$this->assertCan($actor, 'startDiscussion');
|
||||
|
||||
@@ -79,7 +80,7 @@ class StartDiscussionHandler
|
||||
// We will do this by running the PostReply command.
|
||||
try {
|
||||
$post = $this->bus->dispatch(
|
||||
new PostReply($discussion->id, $actor, $data)
|
||||
new PostReply($discussion->id, $actor, $data, $ipAddress)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$discussion->delete();
|
||||
|
Reference in New Issue
Block a user