EvanMailboxService¶
| Source | mailbox |
|---|
Blockchain core description class wrapper.
mails-object[]: all mail cache;newMailCount-number(default = 0): newly received mail count;readMails-Array<string>: all mails that were already viewed (cached into local storage);receivedMails-object[]: received mail cache;sendMailQueueId-qr-code-scanner module: queue id to handle mail sending;sentMails- object[]: send mail cache;totalReceivedMailCount-number: total received mail count;totalSentMailCount-number: total sent mail count;
checkNewMails¶
mailboxService.checkNewMails();
Check for new mails and set the newMails property to false / true when new mails incoming
Returns¶
Promise returns void: resolved when done
Example¶
setInterval(() => this.mailboxService.checkNewMails());
getReadMails¶
mailboxService.getReadMails();
Check read mails within localStorage cache and return them.
Returns¶
Array<string>: readed mails from localStorage
Example¶
this.mailboxService.getReadMails() // [ '0x00...', '0x100...' ]
getReadMailsCount¶
mailboxService.getReadMailsCount();
Get read mail count
Returns¶
number: count of read mails
addReadMails¶
mailboxService.addReadMails(mailId);
Add a mail id to the mail read array within the localStorage
Parameters¶
mailId-string: mail id
syncLastReadCount¶
mailboxService.syncLastReadCount();
Check for new mails and update the last read mail count
showMailModal¶
mailboxService.showMailModal(modalService, alertTitle, alertText, title, body);
Show a mail modal, to provide the user the possility to change the email text before sending.
Have a look at MailDialogComponent
Parameters¶
modalService-string: modal service (must to be inclued, to prevent recursive services)alertTitle-string: title of the modalalertText-string: sub text of the modaltitle-string: title text of the mailbody-string: body text of the mail
Returns¶
Promise returns any: adjusted mail result
Example¶
await this.mailboxService
.showMailModal(
this.modalService,
'_dappcontacts.invitation-message',
'_dappcontacts.invitation-message-long',
'_dappcontacts.invitation-text.title',
'_dappcontacts.invitation-text.body',
);
raiseMailLoadCount¶
mailboxService.raiseMailLoadCount(raise, type);
Increase the mail count for a specific type
Parameters¶
raise-number: number to raise the mail count withtype-string: sent / received
getMails¶
mailboxService.getMails();
Load the mails for the current account.
Parameters¶
options-object: The options used for callingfrom-string(optional): The address the call “transaction” should be made from
callback-Function(optional): This callback will be fired..somethingElse-string(optional): this can be set if required, defaults to"latest"
Returns¶
Promise returns void: resolved when done
{
receivedMails: [ this.getMail() ],
sentMails: [ ... ]
}
getMail¶
mailboxService.getMail(mailId);
Get a mail with a mail id.
Parameters¶
mailId-string: TThe mail identifier
Returns¶
Promise returns any: return the mail
{
"id": "0x00000000000000000000000000000000000000fa",
"content": {
"from": "0xe70dfbc43369DE771d357fA4a6559be2eF16772f",
"fromAlias": "Another user",
"title": "contact request",
"body": "hello,\n\ni want to add you as a contact.\n\nWith kind regards,\n\nAnother user",
"attachments": [
{
"type": "commKey",
"key": "9430..."
}
],
"sent": 1526626132635,
"to": "0xCCC..."
},
"cryptoInfo": {
"originator": "0xd926...",
"keyLength": 256,
"algorithm": "aes-256-cbc"
}
}
sendMail¶
mailboxService.sendMail(mail, from, to);
Send an mail, using the queue.
Parameters¶
mail-string: mail objectfrom-string: account id fromto-string: to account id
Returns¶
Promise returns void: resolved when done
Example¶
this.mailboxService.sendMail({
content: {
sent: new Date().getTime(),
from: this.myAccountId,
to: this.mail.content.from,
title: this.mail.content.title,
body: this.answer,
}
}, '0x000', '0x001')
sendAnswer¶
mailboxService.sendAnswer(mail, from, to);
Send an mail answer, using the queue.
Parameters¶
mail-string: mail objectfrom-string: account id fromto-string: to account id
Returns¶
Promise returns void: resolved when done
Example¶
this.mailboxService.sendAnswer({
parentId: this.mailId,
content: {
sent: new Date().getTime(),
from: this.myAccountId,
to: this.mail.content.from,
title: this.mail.content.title,
body: this.answer,
}
}, '0x000', '0x001')