DigitalState / Platform-Communication-Bundle

OroPlatform bundle that provide multi-channel/Omni-Channel Message generation with query builder: SMS, Email, Inbox, IVR, Twitter, Facebook, etc -- DEVELOPMENT REPO
Other
3 stars 4 forks source link

Modifications made to the platform-communication-bundle #17

Open hb7777 opened 7 years ago

hb7777 commented 7 years ago

Modifications made to the platform-transport-bundle

file: Model/Message.php

Added:

There are scenarios where the input data do not exist in the Oro or DS databases. For example, when a user creates an account in the MTL citizen system. His account is created in gluu and a json parameter is passed to the transport containing his email address, etc. needed to send him an account creation confirmation email, to activate his account.

Modifications made to the platform-communication-bundle

files: Channel/AbstractChannel.php Entity/Message.php Manager/CommunicationManager.php

git diff Channel/AbstractChannel.php $persona = $this->personaManager->getList(null, null, [ "-" 'user' => $message->getUser(), "-" 'type' => 'default' "+" 'user' => $message->getUser() ]);

We should pass the full user entity instead of just what in the user persona entity

$persona = array_shift($persona); "-" $to = $persona->getData($message->getChannel()->getDefaultTo()); "+" if (null !== $persona) { "+" $to = $persona->getData($message->getChannel()->getDefaultTo()); "+" } else { "+" $to = $message->getData("to"); "+" }

There are scenarios where there won't be a user entity, but only what's in the input parameters, so the property data will contain what has been passed.

$messageModel = new MessageModel; $messageModel ->setTo($to) "+" ->setUser($message->getUser()) "+" ->setData($message->getData()) ->setTitle($message->getTitle()) "+" ->setTemplate($message->getTemplate()) ->setContent($message->getPresentation());

The message entity has to contain a reference to the user entity if available and the data property contains the input parameters passed. The template property is needed to keep a record of what template was used when this message was created. Stephen suggests having a template versioning system and used the template version ID here instead of the template content, like I did because of time constraint.

"-" $this->transport->send($messageModel); "+" $this->transport->send($messageModel, $this->transport->getProfile());

The transport profile was not passed to the transport class.

git diff Entity/Message.php

use Attribute\Title; use Attribute\Presentation; use Attribute\SentAt; "+" use Attribute\Data; use Ownership\BusinessUnitAwareTrait;

"+" /* "+" @var string "+" @ORM\Column(name="template", type="text", nullable=true) "+" @Assert\Length(max=65532, maxMessage="ds.entity.presentation.length.max") "+" */ "+" protected $template; # region accessors

Stephen suggests having a template versioning system and used the template version ID here instead, that will save database disk space.

git diff Manager/CommunicationManager.php

->setUser($user) ->setChannel($content->getChannel()) ->setTitle($content->getTitle()) "+" ->setTemplate($content->getTemplate()->getPresentation()) ->setPresentation($content->getPresentation());

Stephen suggests having a template versioning system and used the template version ID here instead, that will save database disk space.