Пример #1
0
 async def send_mail(cls, sender: Facade, recipient: Portfolio) -> Mail:
     """Generate one mail to recipient using a facade saving the mail to the outbox."""
     builder = CreateMail().perform(sender.data.portfolio, recipient)
     message = builder.message(Generate.lipsum_sentence(), Generate.lipsum().decode()).done()
     envelope = WrapEnvelope().perform(sender.data.portfolio, recipient, message)
     await sender.api.mailbox.save_outbox(envelope)
     return message
Пример #2
0
async def prepare_mail(client: Facade, recipient: Portfolio) -> Mail:
    """Generate one mail to recipient using a facade saving the mail to the outbox."""
    message = CreateMail().perform(client.data.portfolio, recipient).message(
        Generate.lipsum_sentence(), Generate.lipsum(100).decode()).done()
    envelope = WrapEnvelope().perform(client.data.portfolio, recipient, message)
    await client.storage.vault.save(
        PurePosixPath("/messages/outbox/" + str(envelope.id) + Helper.extension(Definitions.COM_ENVELOPE)), envelope)
    return message
Пример #3
0
async def inject_mail(server: Facade, sender: PrivatePortfolio, recipient: Portfolio) -> Mail:
    """Generate one mail to recipient using a facade saving the mail to the outbox."""
    message = CreateMail().perform(sender, recipient).message(
        Generate.lipsum_sentence(), Generate.lipsum(100).decode()).done()
    envelope = WrapEnvelope().perform(sender, recipient, message)
    await server.storage.mail.save(
        PurePosixPath("/" + str(envelope.id) + Helper.extension(Definitions.COM_ENVELOPE)), envelope)
    return message
Пример #4
0
 async def inject_mail(cls, server: "Facade", sender: "Facade",
                       recipient: "Portfolio") -> "Mail":
     """Generate one mail to recipient using a facade injecting the mail to the server."""
     builder = MessagePolicy.mail(sender.data.portfolio, recipient)
     message = builder.message(Generate.lipsum_sentence(),
                               Generate.lipsum().decode()).done()
     envelope = EnvelopePolicy.wrap(sender.data.portfolio, recipient,
                                    message)
     await server.storage.mail.save(
         DOCUMENT_PATH[DocType.COM_ENVELOPE].format(dir="",
                                                    file=envelope.id),
         envelope)
     return message