Documentation
¶
Index ¶
- type MessageQueue
- func (msq *MessageQueue) DIDCommSendMessage(userAddress string, input *types.DIDCommMessageInput) error
- func (msq *MessageQueue) DidCommReceiveMessage(message *types.DIDCommMessage) error
- func (mqs *MessageQueue) ProcessDIDCommTask(ctx context.Context, t *asynq.Task) error
- func (mqs *MessageQueue) ProcessSMTPTask(ctx context.Context, t *asynq.Task) error
- func (msq *MessageQueue) ReceiveSMTPMessage(email *abi.Mail, taskId string) error
- func (msq *MessageQueue) SendSMTPMessage(fromMailioAddress string, email *types.SmtpEmailInput, taskId string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
func NewMessageQueue ¶
func NewMessageQueue(dbSelector *repository.CouchDBSelector, env *types.Environment) *MessageQueue
func (*MessageQueue) DIDCommSendMessage ¶
func (msq *MessageQueue) DIDCommSendMessage(userAddress string, input *types.DIDCommMessageInput) error
* Sends an encrypted DIDComm message to the specified recipient(s). The message is validated, logged, and optionally saved in a local database. It handles attachments, validates recipient addresses, and routes the message to the appropriate endpoints. *
func (*MessageQueue) DidCommReceiveMessage ¶
func (msq *MessageQueue) DidCommReceiveMessage(message *types.DIDCommMessage) error
SendMessage sends encrypted DIDComm message to recipient
func (*MessageQueue) ProcessDIDCommTask ¶
processing od DIDComm tasks
func (*MessageQueue) ProcessSMTPTask ¶
Processing of SMTP tasks
func (*MessageQueue) ReceiveSMTPMessage ¶
func (msq *MessageQueue) ReceiveSMTPMessage(email *abi.Mail, taskId string) error
ReceiveSMTPMessage processes an incoming SMTP email message and handles it according to various rules and checks. The function performs the following steps:
- Determines the default folder for the email.
- Checks if the email is marked as spam and adjusts the folder accordingly.
- Prepares the recipients list.
- Iterates over each recipient to perform various checks and actions: a. Retrieves the SMTP handler for the recipient's domain. b. Checks if the user exists in the database. c. Retrieves the user's profile and checks if the user is enabled. d. Checks if the user is over the disk space limit on external disk storages. e. Processes any attachments in the email. f. If the email is not spam, performs additional checks using handshakes and statistics to determine the folder.
- Prepares the email for storage by marshalling it into JSON.
- Constructs a DIDCommMessage for compatibility with the client main JSON structure.
- Saves the email message to the database.
Detailed Description: - The default folder is initially set to `MailioFolderOther`. - If the email's SpamVerdict status is `VerdictStatusFail`, the email is marked as spam and the folder is set to `MailioFolderSpam`. - For each recipient in the email:
- The SMTP handler for the recipient's domain is retrieved using `mailiosmtp.GetHandler`.
- The recipient's email address is hashed and encoded to check for user existence in the database.
- The user's profile is retrieved and checked if it is enabled.
- The total disk usage for the user is calculated and compared against their disk space limit.
- Attachments in the email are processed using `processAttachments`.
- If the email is not marked as spam, additional checks are performed using handshakes and email statistics to determine the appropriate folder.
- The email is marshalled into JSON format and a DIDCommMessage is constructed. - The email message is saved to the database using `userService.SaveMessage`. - Errors are logged using `global.Logger.Log` and appropriate bounce messages are sent using `sendBounce`.
func (*MessageQueue) SendSMTPMessage ¶
func (msq *MessageQueue) SendSMTPMessage(fromMailioAddress string, email *types.SmtpEmailInput, taskId string) error
Sending email message using SMTP 1. Checks if user canceled the email sending 2. deletes the draft message per message ID