-
Notifications
You must be signed in to change notification settings - Fork 117
WIP: Add Sending Mail Possibility to Mesh #1357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
@@ -137,6 +137,18 @@ public abstract class MeshOptions implements Option { | |||
@EnvironmentVariable(name = MESH_MAX_PURGE_BATCH_SIZE, description = "Override the maximum purge batch size.") | |||
private int versionPurgeMaxBatchSize = 10; | |||
|
|||
public MailOptions getMailOptions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use @JsonProperty("mail")
or similar.
@@ -137,6 +137,18 @@ public abstract class MeshOptions implements Option { | |||
@EnvironmentVariable(name = MESH_MAX_PURGE_BATCH_SIZE, description = "Override the maximum purge batch size.") | |||
private int versionPurgeMaxBatchSize = 10; | |||
|
|||
public MailOptions getMailOptions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use @JsonProperty("mail")
or similar.
message.setAttachment(new ArrayList<>()); | ||
|
||
// download all binary data and add as attachments | ||
return Observable.fromIterable(fileFieldNames).flatMapSingle(name -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use BinaryDao
to get the binary stream asynchronously.
message.setAttachment(new ArrayList<>()); | ||
|
||
// download all binary data and add as attachments | ||
return Observable.fromIterable(fileFieldNames).flatMapSingle(name -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use BinaryDao
to get the binary stream asynchronously.
Good work by now, thanks. Keep making it 👍 |
1 similar comment
Good work by now, thanks. Keep making it 👍 |
HibJob mailSendingJob = Tx.get().jobDao().enqueueMailSending(user, new Timestamp(System.currentTimeMillis()).getTime(), ac.getBodyAsString()); | ||
|
||
if(mailSendingJob.getStatus() == JobStatus.FAILED){ | ||
Tx.get().jobDao().enqueueMailSending(user,new Timestamp(System.currentTimeMillis()).getTime() + meshOptions.getMailOptions().getRetry(), ac.getBodyAsString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you have to reassign mailSendingJob
, in order the following status check to work.
Tx.get().jobDao().enqueueMailSending(user,new Timestamp(System.currentTimeMillis()).getTime() + meshOptions.getMailOptions().getRetry(), ac.getBodyAsString()); | ||
} | ||
if (mailSendingJob.getStatus() == JobStatus.COMPLETED) { | ||
Tx.get().jobDao().delete(mailSendingJob, new DummyBulkActionContext()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here you have to reassign it again to get the eventual status, and return it appropriately.
import io.vertx.ext.web.FileUpload; | ||
|
||
/** | ||
* @see MicronodeMigrationContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a micronode but a general action context.
MailClient mailClient = MailClient.create(vertx, config); | ||
String mail = db.tx(mailJob::getMail); | ||
|
||
MailSendingRequest request = JsonUtil.readValue(mail, MailSendingRequest.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These approach of having the whole email as JSON is not that much useful. Better to send/store the mail parts distinctly, as done in the sending context. This will allow the client to fetch/filter/reuse the jobs, if required, and gives better control over sending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that I have also data that cannot be send in primitive data like Lists of Strings for example
}); | ||
}) | ||
.lastOrError().doOnError(th-> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fill the error processing.
* @param mail | ||
* @return | ||
*/ | ||
HibJob enqueueMailSending(HibUser user, long now, String mail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API should also be changed accordingly, to accept distinct email parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HibJob enququeMailSending(HibUser user, long time, List<String> toAddrs, List<String> ccAddrs, List<String> bccAddrs, String title, String body, List<String> attachmentUuids)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HibJob enququeMailSending(HibUser user, long time, MailSendingRequest request)
|
||
import com.gentics.mesh.core.rest.common.AbstractResponse; | ||
|
||
public class MailSendingRequest extends AbstractResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a response, not a request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good looking in general. I'd ask to change the sending and storage API.
Abstract
Checklist
General
/CHANGELOG.adoc
On API Changes