@Test void exportingBlobShouldSendAMail() { BlobId blobId = Mono.from(blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT, LOW_COST)).block(); String explanation = "The content of a deleted message vault had been shared with you."; testee.blobId(blobId) .with(MailAddressFixture.RECIPIENT1) .explanation(explanation) .noFileCustomPrefix() .noFileExtension() .export(); assertThat(mailetContext.getSentMails()).hasSize(1) .element(0) .satisfies(sentMail -> { try { assertThat(sentMail.getSender()).isEqualTo(MailAddressFixture.POSTMASTER_AT_JAMES); assertThat(sentMail.getRecipients()).containsExactly(MailAddressFixture.RECIPIENT1); assertThat(sentMail.getMsg().getFrom()).contains(new InternetAddress(MailAddressFixture.POSTMASTER_AT_JAMES.asString())); assertThat(sentMail.getMsg().getRecipients(Message.RecipientType.TO)).contains(new InternetAddress(MailAddressFixture.RECIPIENT1.asString())); assertThat(sentMail.getMsg().getSubject()).isEqualTo("Some content had had just been exported"); String mailContent = MimeMessageUtil.asString(sentMail.getMsg()); assertThat(mailContent).contains(explanation); assertThat(mailContent).contains("The content of this blob can be read directly on James host filesystem (james-host) in this file: "); } catch (Exception e) { throw new RuntimeException(e); } }); }
@Override public ShareeStage blobId(BlobId blobId) { return mailAddress -> explanation -> fileCustomPrefix -> fileExtension -> () -> { String fileUrl = copyBlobToFile(blobId, fileCustomPrefix, fileExtension); sendMail(mailAddress, fileUrl, explanation); }; }
LocalFileBlobExportMechanism implements BlobExportMechanism { @Override public ShareeStage blobId(BlobId blobId) { return mailAddress -> explanation -> fileCustomPrefix -> fileExtension -> () -> { String fileUrl = copyBlobToFile(blobId, fileCustomPrefix, fileExtension); sendMail(mailAddress, fileUrl, explanation); }; } }
LocalFileBlobExportMechanism implements BlobExportMechanism { @Override public ShareeStage blobId(BlobId blobId) { return mailAddress -> explanation -> fileCustomPrefix -> fileExtension -> () -> { String fileUrl = copyBlobToFile(blobId, fileCustomPrefix, fileExtension); sendMail(mailAddress, fileUrl, explanation); }; } @VisibleForTesting @Inject  LocalFileBlobExportMechanism(MailetContext mailetContext, BlobStore blobStore, FileSystem fileSystem, DNSService dnsService, Configuration configuration); }
LocalFileBlobExportMechanism implements BlobExportMechanism { @Override public ShareeStage blobId(BlobId blobId) { return mailAddress -> explanation -> fileCustomPrefix -> fileExtension -> () -> { String fileUrl = copyBlobToFile(blobId, fileCustomPrefix, fileExtension); sendMail(mailAddress, fileUrl, explanation); }; } @VisibleForTesting @Inject  LocalFileBlobExportMechanism(MailetContext mailetContext, BlobStore blobStore, FileSystem fileSystem, DNSService dnsService, Configuration configuration); @Override ShareeStage blobId(BlobId blobId); }
LocalFileBlobExportMechanism implements BlobExportMechanism { @Override public ShareeStage blobId(BlobId blobId) { return mailAddress -> explanation -> fileCustomPrefix -> fileExtension -> () -> { String fileUrl = copyBlobToFile(blobId, fileCustomPrefix, fileExtension); sendMail(mailAddress, fileUrl, explanation); }; } @VisibleForTesting @Inject  LocalFileBlobExportMechanism(MailetContext mailetContext, BlobStore blobStore, FileSystem fileSystem, DNSService dnsService, Configuration configuration); @Override ShareeStage blobId(BlobId blobId);  }