Messenger

Contracts

MessengerRepositoryContract

The contract defines methods to add and show/list messages.

Namespace

Plenty\Modules\Messenger\Contracts

Methods

public add(array $data):Message

Create a new Message.

Parameters
array $data
public show(string $uuid):void

Show a message with all its successors.

Parameters
string $uuid The UUID5 of the Message.
public list(string $uuid = null, bool $successors = true, int $amount = self::DEFAULT_MESSAGES_AMOUNT):array

List messages.

Parameters
string $uuid The reference UUID5 of the message to start from (excluding). If not set, the uuid of the newest message will be used.
bool $successors If set to FALSE, the messages older than the referenced message will be returned.
int $amount The amount of messages to list (defaults to 50)
public updateReadBy(int $readBy, string $uuid):void

Update ReadBy Array of message

Parameters
int $readBy
string $uuid
public updateVisibility(array $data, string $uuid):void

Update the visibility of the message.

Parameters
array $data The message with the data to be updates
string $uuid The uuid of the messages.
public setDone(string $doneAt = null, string $uuid):void

Set the doneAt date in the message.

Parameters
string $doneAt The doneAt date as ISO date string
string $uuid The uuid of the message.
public delete(string $uuid):int

Deletes a message stream by uuid.

Parameters
string $uuid
public getAttachment(string $uuid, string $filename):Attachment

Get a message attachment.

Parameters
string $uuid The message uuid
string $filename The filename of the attachment.
public setFilters(array $filters = []):void

Sets the filter array.

Parameters
array $filters
public getFilters():void

Returns the filter array.

public getConditions():void

Returns a collection of parsed filters as Condition object

public clearFilters():void

Clears the filter array.

Models

MessageMetaData

The messenger MessageMetaData model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
array readBy array of users

Methods

public toArray()

Returns this model as an array.

MessageLinkedTo

The messenger MessageLinkedTo model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string type The type of the link (one of {@link MessageTypesService::LINKED_TO_TYPE_MESSAGE}, {@link MessageTypesService::LINKED_TO_TYPE_ORDER}, {@link MessageTypesService::LINKED_TO_TYPE_CONTACT} and {@link MessageTypesService::LINKED_TO_TYPE_PAYMENT})
value The value of the link. For type {@link MessageTypesService::LINKED_TO_TYPE_MESSAGE} it is a string (uuid5) and an integer otherwise.
typeId This can be the id of a sub type (e.g. the order subTypeId). (optional)

Methods

public toArray()

Returns this model as an array.

MessageReferrer

The messenger MessageReferrer model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string type The type of the from instance (one of {@link MessageTypesService::REFERRER_TYPE_SYSTEM}, {@link MessageTypesService::REFERRER_TYPE_BACKEND}, {@link MessageTypesService::REFERRER_TYPE_REST} and {@link MessageTypesService::REFERRER_TYPE_PLUGIN})
value The value of the instance. It is an integer (the user id) for type {@link MessageTypesService::REFERRER_TYPE_SYSTEM}, {@link MessageTypesService::REFERRER_TYPE_BACKEND} and {@link MessageTypesService::REFERRER_TYPE_REST} and a string (the plugin name) for type {@link MessageTypesService::REFERRER_TYPE_PLUGIN}.
string name An optional name for the instance. For type {@link MessageTypesService::REFERRER_TYPE_PLUGIN} it is the plugin namespace, the user name otherwise.

Methods

public toArray()

Returns this model as an array.

MessageFrom

The messenger MessageFrom model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string type The type of the from instance (one of {@link MessageTypesService::FROM_TYPE_USER}, {@link MessageTypesService::FROM_TYPE_CONTACT} and {@link MessageTypesService::FROM_TYPE_EMAIL})
value The value of the instance. For type {@link MessageTypesService::FROM_TYPE_EMAIL} it is a string (the email) and the id of the user or the contact otherwise.
string name An optional name for the instance, e.g. the real name for type {@link MessageTypesService::FROM_TYPE_EMAIL}

Methods

public toArray()

Returns this model as an array.

Attachment

The messenger Attachment model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string name The file name of the attachment
string message The uuid of the message the attachment belongs to.
int size The size of the attachment in bytes.
string contentType The content type fo the attachment.
string content The content of the attachment.
string createdAt

Methods

public toArray()

Returns this model as an array.

Message

The messenger Message model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string uuid The UUID5 identifier of the message
string plentyIdHash The plenty ID hash
string parentUuid The uuid5 of the parent message.
array linkedTo An array with MessageLinkedTo instances.
MessageFrom from The sender of the message as MessageFrom instance.
MessageTo to The user and role ids and emails recieving the message.
bool whispered Whether the message is wispered (not visible for the contact/order linked to the message) or not.
array tags An array with tag IDs assigned to the message
string title The title of the message
string preview The first two lines of the message without any markup
string message The content of the message
int attachedFilesCount The amount of attached files (readonly)
MessageReferrer referrer The message referrer.
MessageMetaData metaData The message metadata
string doneAt The date the messages setted done.
string createdAt The creation date of the message.
string updatedAt The date of the last update of the message.
string deletedAt The date the message was deleted.
int deletedBy The id of the user deleted the message.
array attachments The message attachments.

Methods

public toArray()

Returns this model as an array.

MessageTo

The messenger MessageTo model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
array user An array with user ids of user recieving the message.
array role An array with user role ids of user roles recieving the message.
array email An array with emails recieving the message
bool allUsers A flag indicating that all system user recieve the message.

Methods

public toArray()

Returns this model as an array.