im/Messages

A collection of IM messages bound to IM accounts and subscribers. The collection is created and used by the microservice 'im'. Is of type history, partitioned and addressed using dates.

Entities for received messages are created by scripts for receiving messages from IM servers. Sent message entities are created via API or other system services.

Messages have states that affect the service process. For example, to send a message the state must be set to 'sending', and after sending the message it is automatically set to 'sent'.

All attachments, HTML content, and the native unattached content of the email are saved as attachments, stored in the file system. This introduces limitations on the file system, whose inodes can be quickly depleted if initially limited where attachments are stored.

Storage Type: history.

Table 1. Class fields
Field Description

id

Identifier.

account_id

remoteParty_id

Identifier directory.

dateTime

Date-time of entity creation. It is used, among other things, when defining the storage partition in the database.

messageDirection

Message Direction:

  • in - incoming message.

  • out - outgoing/sent message.

messageType

Message Type:

  • text - text

  • image - image

  • document - document

  • audio - audio

  • video - video

  • hyperlink - external link

  • buttons - inline keyboard

  • undefined - other content types

messageState

Writing condition:

  • sending - a message ready to be sent.

  • sent - message sent.

  • delivered - the message has been delivered to the recipient (only for those services where this is supported).

  • read - the message has been read by the recipient (only for those services where this is supported).

  • received - the message you received.

  • error - sending error.

  • undefined - unknown condition.

statusText

Filled with the error content, if the received message has error state, or the error occurred during sending.

text

Message Text

file

A file attachment that matches the type of message.

data

An object with data of other types, such as a structure for a keyboard (sent message of type 'buttons') or a selected item on an inline keyboard (received message of type 'buttons').

For example, sending a message of type 'buttons' to Telegram may contain this field value 'data':

{
  "inline_keyboard": [
    [
       {"text": "1", "callback_data": "ZZZ"}
    ],
    [
       {"text": "2.1", "callback_data": "AAA"},
       {"text": "2.2", "callback_data": "BBB"}
    ]
  ]
}

When the button 2.1 is clicked, a message will be received and an entity with type 'buttons' and field value will be generated 'data':

{
   "callback_data": "AAA"
}

sendOptions

Options for the message to be sent.

nativeMessageType

The original type of message in the IM service.

  • text - text.

  • callback_query - menu selections.

rawMessage

The original unopened incoming email.