This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhanced conversation snapshot (#120)
* feat: Enhanced conversation snapshot * fix: Move CW signature above read history
- Loading branch information
Showing
12 changed files
with
234 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
module/Api/src/Domain/Command/Messaging/Conversation/StoreEnhancedSnapshot.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Api\Domain\Command\Messaging\Conversation; | ||
|
||
use Dvsa\Olcs\Transfer\Command\AbstractCommand; | ||
use Dvsa\Olcs\Transfer\FieldType\Traits\Identity; | ||
|
||
final class StoreEnhancedSnapshot extends AbstractCommand | ||
{ | ||
use Identity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
module/Api/src/Domain/CommandHandler/Messaging/Conversation/StoreEnhancedSnapshot.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Api\Domain\CommandHandler\Messaging\Conversation; | ||
|
||
use Dvsa\Olcs\Api\Domain\CommandHandler\AbstractCreateSnapshotHandler; | ||
use Dvsa\Olcs\Api\Domain\Repository\Conversation; | ||
use Dvsa\Olcs\Api\Entity\System\Category; | ||
use Dvsa\Olcs\Api\Entity\System\SubCategory; | ||
use Dvsa\Olcs\Snapshot\Service\Snapshots\Messaging\EnhancedGenerator; | ||
|
||
final class StoreEnhancedSnapshot extends AbstractCreateSnapshotHandler | ||
{ | ||
protected $repoServiceName = Conversation::class; | ||
protected $generatorClass = EnhancedGenerator::class; | ||
protected $documentCategory = Category::CATEGORY_LICENSING; | ||
protected $documentSubCategory = SubCategory::DOC_SUB_CATEGORY_LICENCING_OTHER_DOCUMENTS; | ||
protected $documentDescription = 'Enhanced Conversation Snapshot'; | ||
protected $documentLinkId = 'messagingConversation'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function getDocumentDescription($entity): string | ||
{ | ||
return $this->documentDescription; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
module/Snapshot/src/Service/Snapshots/Messaging/EnhancedGenerator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Snapshot\Service\Snapshots\Messaging; | ||
|
||
use Doctrine\ORM\AbstractQuery; | ||
use Dvsa\Olcs\Api\Domain\Repository\Message as MessageRepo; | ||
use Dvsa\Olcs\Api\Entity\Messaging\MessagingConversation; | ||
use Dvsa\Olcs\Api\Entity\Messaging\MessagingMessage; | ||
use Dvsa\Olcs\Snapshot\Service\Snapshots\AbstractGenerator; | ||
use Dvsa\Olcs\Snapshot\Service\Snapshots\AbstractGeneratorServices; | ||
use Dvsa\Olcs\Snapshot\Service\Snapshots\SnapshotGeneratorInterface; | ||
use Dvsa\Olcs\Transfer\Query\Messaging\Messages\ByConversation; | ||
|
||
class EnhancedGenerator extends AbstractGenerator implements SnapshotGeneratorInterface | ||
{ | ||
protected MessageRepo $messageRepository; | ||
protected MessagingConversation $conversation; | ||
|
||
public function __construct( | ||
AbstractGeneratorServices $abstractGeneratorServices, | ||
MessageRepo $messageRepository | ||
) { | ||
parent::__construct($abstractGeneratorServices); | ||
|
||
$this->messageRepository = $messageRepository; | ||
} | ||
|
||
public function setData($data): void | ||
{ | ||
$this->conversation = $data['entity']; | ||
} | ||
|
||
public function generate(): string | ||
{ | ||
$query = $this->messageRepository->getBaseMessageListWithContentQuery( | ||
ByConversation::create( | ||
[ | ||
'page' => 1, | ||
'limit' => 1000, | ||
], | ||
), | ||
); | ||
$query = $this->messageRepository->filterByConversationId($query, $this->conversation->getId()); | ||
/** @var MessagingMessage[] $messages */ | ||
$messages = $this->messageRepository->fetchPaginatedList($query, AbstractQuery::HYDRATE_OBJECT); | ||
|
||
return $this->generateReadonly( | ||
[ | ||
'conversation' => $this->conversation, | ||
'messages' => $messages, | ||
'enhanced' => true, | ||
], | ||
'conversation', | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
module/Snapshot/src/Service/Snapshots/Messaging/EnhancedGeneratorFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Snapshot\Service\Snapshots\Messaging; | ||
|
||
use Dvsa\Olcs\Api\Domain\Repository\Message as MessageRepository; | ||
use Dvsa\Olcs\Snapshot\Service\Snapshots\AbstractGeneratorServices; | ||
use Laminas\ServiceManager\Factory\FactoryInterface; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class EnhancedGeneratorFactory implements FactoryInterface | ||
{ | ||
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) | ||
{ | ||
return new EnhancedGenerator( | ||
$container->get(AbstractGeneratorServices::class), | ||
$container->get('RepositoryServiceManager')->get(MessageRepository::class), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...module/Api/src/Domain/CommandHandler/Messaging/Conversation/StoreEnhancedSnapshotTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\OlcsTest\Api\Domain\CommandHandler\Messaging\Conversation; | ||
|
||
use Dvsa\Olcs\Api\Domain\Command\Messaging\Conversation\StoreEnhancedSnapshot as Cmd; | ||
use Dvsa\Olcs\Api\Domain\CommandHandler\Messaging\Conversation\StoreEnhancedSnapshot as Sut; | ||
use Dvsa\Olcs\Api\Domain\Repository\Conversation; | ||
use Dvsa\Olcs\Api\Entity\Messaging\MessagingConversation; | ||
use Dvsa\Olcs\Api\Entity\System\Category; | ||
use Dvsa\Olcs\Api\Entity\System\SubCategory; | ||
use Dvsa\Olcs\Snapshot\Service\Snapshots\Messaging\EnhancedGenerator; | ||
use Dvsa\OlcsTest\Api\Domain\CommandHandler\AbstractCreateSnapshotHandlerTest; | ||
|
||
class StoreEnhancedSnapshotTest extends AbstractCreateSnapshotHandlerTest | ||
{ | ||
protected $cmdClass = Cmd::class; | ||
protected $sutClass = Sut::class; | ||
protected $repoServiceName = Conversation::class; | ||
protected $repoClass = Conversation::class; | ||
protected $entityClass = MessagingConversation::class; | ||
protected $documentCategory = Category::CATEGORY_LICENSING; | ||
protected $documentSubCategory = SubCategory::DOC_SUB_CATEGORY_LICENCING_OTHER_DOCUMENTS; | ||
protected $documentDescription = 'Enhanced Conversation Snapshot'; | ||
protected $documentLinkId = 'messagingConversation'; | ||
protected $documentLinkValue = 999; | ||
protected $generatorClass = EnhancedGenerator::class; | ||
} |