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

Commit

Permalink
Add missing meta.delete_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Schmidmeister committed Jan 11, 2017
1 parent 073dab8 commit dcbfd54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion API/src/Commands/Posts/ArchivePostCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ public function __construct(PostService $postService, ElasticBackend $elasticBac
public function execute(string $postId): string
{
$archived = $this->postService->archivePost($postId);
$timestamp = (new StringDateTime($archived))->getTimestamp();

$this->elasticBackend->updateDocument('post', $postId, [
'archived' => (new StringDateTime($archived))->getTimestamp()
'archived' => $timestamp,
'meta' => [
'delete_timestamp' => $timestamp + 3600 * 24 * 30
]
]);

return $archived;
Expand Down
16 changes: 14 additions & 2 deletions API/src/Commands/Posts/RestorePostCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace Timetabio\API\Commands\Posts
{
use Timetabio\API\DataStore\DataStoreWriter;
use Timetabio\API\Services\PostService;
use Timetabio\Framework\Backends\ElasticBackend;

Expand All @@ -24,19 +25,30 @@ class RestorePostCommand
*/
private $elasticBackend;

public function __construct(PostService $postService, ElasticBackend $elasticBackend)
/**
* @var DataStoreWriter
*/
private $dataStoreWriter;

public function __construct(PostService $postService, ElasticBackend $elasticBackend, DataStoreWriter $dataStoreWriter)
{
$this->postService = $postService;
$this->elasticBackend = $elasticBackend;
$this->dataStoreWriter = $dataStoreWriter;
}

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

$this->elasticBackend->updateDocument('post', $postId, [
'archived' => null
'archived' => null,
'meta' => [
'delete_timestamp' => null
]
]);

$this->dataStoreWriter->queueTask(new \Timetabio\Library\Tasks\IndexPostTask($postId));
}
}
}
3 changes: 2 additions & 1 deletion API/src/Factories/CommandFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public function createRestorePostCommand(): \Timetabio\API\Commands\Posts\Restor
{
return new \Timetabio\API\Commands\Posts\RestorePostCommand(
$this->getMasterFactory()->createPostService(),
$this->getMasterFactory()->createElasticBackend()
$this->getMasterFactory()->createElasticBackend(),
$this->getMasterFactory()->createDataStoreWriter()
);
}
}
Expand Down

0 comments on commit dcbfd54

Please sign in to comment.