Skip to content
This repository was archived by the owner on May 8, 2018. It is now read-only.

Commit dcbfd54

Browse files
author
Ruben Schmidmeister
committed
Add missing meta.delete_timestamp
1 parent 073dab8 commit dcbfd54

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

API/src/Commands/Posts/ArchivePostCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ public function __construct(PostService $postService, ElasticBackend $elasticBac
3434
public function execute(string $postId): string
3535
{
3636
$archived = $this->postService->archivePost($postId);
37+
$timestamp = (new StringDateTime($archived))->getTimestamp();
3738

3839
$this->elasticBackend->updateDocument('post', $postId, [
39-
'archived' => (new StringDateTime($archived))->getTimestamp()
40+
'archived' => $timestamp,
41+
'meta' => [
42+
'delete_timestamp' => $timestamp + 3600 * 24 * 30
43+
]
4044
]);
4145

4246
return $archived;

API/src/Commands/Posts/RestorePostCommand.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
namespace Timetabio\API\Commands\Posts
1111
{
12+
use Timetabio\API\DataStore\DataStoreWriter;
1213
use Timetabio\API\Services\PostService;
1314
use Timetabio\Framework\Backends\ElasticBackend;
1415

@@ -24,19 +25,30 @@ class RestorePostCommand
2425
*/
2526
private $elasticBackend;
2627

27-
public function __construct(PostService $postService, ElasticBackend $elasticBackend)
28+
/**
29+
* @var DataStoreWriter
30+
*/
31+
private $dataStoreWriter;
32+
33+
public function __construct(PostService $postService, ElasticBackend $elasticBackend, DataStoreWriter $dataStoreWriter)
2834
{
2935
$this->postService = $postService;
3036
$this->elasticBackend = $elasticBackend;
37+
$this->dataStoreWriter = $dataStoreWriter;
3138
}
3239

3340
public function execute(string $postId): void
3441
{
3542
$this->postService->restorePost($postId);
3643

3744
$this->elasticBackend->updateDocument('post', $postId, [
38-
'archived' => null
45+
'archived' => null,
46+
'meta' => [
47+
'delete_timestamp' => null
48+
]
3949
]);
50+
51+
$this->dataStoreWriter->queueTask(new \Timetabio\Library\Tasks\IndexPostTask($postId));
4052
}
4153
}
4254
}

API/src/Factories/CommandFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ public function createRestorePostCommand(): \Timetabio\API\Commands\Posts\Restor
222222
{
223223
return new \Timetabio\API\Commands\Posts\RestorePostCommand(
224224
$this->getMasterFactory()->createPostService(),
225-
$this->getMasterFactory()->createElasticBackend()
225+
$this->getMasterFactory()->createElasticBackend(),
226+
$this->getMasterFactory()->createDataStoreWriter()
226227
);
227228
}
228229
}

0 commit comments

Comments
 (0)