Git Product home page Git Product logo

jmix-email's Introduction

jmix-email's People

Contributors

desire456 avatar dtaimanov avatar flaurite avatar glebfox avatar glebshalyganov avatar gorbunkov avatar knstvk avatar m-orlova avatar plakhov avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmix-email's Issues

Confusing attemptsCount and attemptsMade column names in SendingMessage entity

The SendingMessage entity contains attemptsCount and attemptsMade column.

attemptsMade stores a number of actual attempts number that have been made.

attemptsCount store a limit number of attempts after which the message status is changed to NOT_SENT. In UI this field is actually named Attempts limit that explains the meaning much better than attempts count.

Database column and entity property must be renamed: attemptsCount -> attemptsLimit.

The configuration property should also be renamed: jmix.email.defaultSendingAttemptsCount -> jmix.email.defaultSendingAttemptsLimit

After the issue is fixed, the documentation must also be modified: https://docs.jmix.io/jmix/0.x/email/configuration.html#jmix.email.defaultSendingAttemptsCount - the issue in jmix-docs GitHub repository must be created.

Also, the article about migration from CUBA must be updated - the liquibase changelog must rename the database column.

Define Quartz scheduler beans inside the add-on

The add-on requires a scheduler for queued emails sending. Currently we recommend users to add the spring-boot-starter-quartz to their project and to define all quartz beans in projects. Probably we can simplify the process by doing the following:

  1. Define a compile-time dependency to the quartz in the add-on

  2. Create an auto-configuration that will instantiate required quartz beans if quartz is in the classpath and if a special application property is set, e.g. jmix.email.useDefaultQuartzConfiguration is true (default behavior).

The Quartz beans:

public class EmailSendingJob implements Job {

    @Autowired
    private Emailer emailer;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        emailer.processQueuedEmails();
    }
}

@Bean
JobDetail emailSendingJob() {
    return JobBuilder.newJob()
            .ofType(EmailSendingJob.class)
            .storeDurably()
            .withIdentity("emailSending")
            .build();
}

@Bean
Trigger emailSendingTrigger() {
    return TriggerBuilder.newTrigger()
            .forJob(emailSendingJob())
            .startNow()
            .withSchedule(CronScheduleBuilder.cronSchedule("0 * * * * ?")) 
            .build();
}
  1. The cron expression should be taken from the application property, e.g. jmix.email.emailSendingCron

See also jmix-projects/jmix-search#53

Change the default emaill order on the Email History screen

Environment:
Jmix version: 1.0.0-SNAPSHOT
IntelliJ version: IntelliJ IDEA 2020.3.3 (Community Edition)

Description of the bug

  1. Install email add-on
  2. Run application
  3. Send two or more emails
  4. Open Administration -> Email History

ER:
The emails order by "Created at" desc. Later emails are displayed higher up in the list
AR:
Unordered list of emails

Fix messages

  1. Fix English messages according to the rules:
    • Capitalize only first letter in a sentence. Do not use Title Case.
    • Use all capital letters for abbreviations, i.e. JPQL, XML (not Jpql, xml).
  2. Make sure there are no unused messages.
  3. Copy messages.properties to jmix-translations
  4. Create or fix messages_ru.properties in jmix-translations

Fix messages

  1. Fix English messages according to the rules:
    • Capitalize only first letter in a sentence. Do not use Title Case.
    • Use all capital letters for abbreviations, i.e. JPQL, XML (not Jpql, xml).
  2. Make sure there are no unused messages.
  3. Copy messages.properties to jmix-translations
  4. Create or fix messages_ru.properties in jmix-translations

Add fields CC, BCC to the right pannel of Email History

Environment
Jmix version: 1.0.0-SNAPSHOT

Description of the bug

  1. Install email add-on
  2. Run aplication
  3. Go to the tab Administration -> Email History

AR:
The following fields are missing in the right panel: Cc, Bcc
ER:
Cc and Bcc fields are added to the right panel

Message status does not change when the maximum number of attempts is reached

Environment:
Jmix version: 1.0.0-SNAPSHOT
IntelliJ version: IntelliJ IDEA 2020.3.3 (Community Edition)

Description of the bug:

  1. Install email add-on
  2. Run application
  3. Asynchronous send email with incorrect "from" email
  4. use emailer.processQueuedEmails(); 10 times
    note: because default value of jmix.email.defaultSendingAttemptsCount=10
  5. Open Administration -> Email History

ER:
Since 10 attempts have been made, the status of the message should change to "Not Sent"
AR:
After 10 attempts the status "Queue", after one more attempt status was changed to "Not Sent"

Add README.md file

The file must contain a brief description of application properties that need to be set:

  • some properties must be set in a standard for spring-email way: spring.mail.XXX
  • some properties are jmix specific, e.g. fromAddress

There is no need to list all possible properties there, just give an example of how to setup sending from any popular mail service, e.g. Gmail.

Beans created by EmailSendingScheduleAutoConfiguration should have explicit names

Otherwise when both IMAP and Email add-ons are included to the project, the application fails with the exception:

The bean 'emailSendingTrigger', defined in class path resource [io/jmix/autoconfigure/imap/ImapSyncScheduleAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [io/jmix/autoconfigure/email/EmailSendingScheduleAutoConfiguration.class] and overriding is disabled.

The attempt limit field is empty

Environment
Jmix version: 1.0.0-SNAPSHOT

Description of the bug

  1. Install email add-on
  2. Create new screen
  3. Add button to the screen. Add Click Event containing emailer.sendEmailAsync(emailInfo) and definition of emailInfo
  4. Run application and click on created button
  5. Open Administration -> Email history
  6. Click on created mail

ER:
Field "Attempt limit" contains number equal parameter jmix.email.defaultSendingAttemptsCount. It makes sense to display this field only for messages with the status "Queue".
AR:
Field "Attempt limit" is empty and displaying for all messages

Sorting by address field is not available

Environment:
Jmix version: 1.0.0-SNAPSHOT
IntelliJ version: IntelliJ IDEA 2020.3.3 (Community Edition)

Description of the bug

  1. Install email add-on
  2. Run application
  3. Send two or more emails
  4. Open Administration -> Email History
  5. Click on the name of the address column

ER:
The emails order by "Address"
AR:
Sorting is not applied. No arrows are displayed next to the column name

Adding attachments to email doesn't work with PostgreSQL

Enviroment:
JMIX plugin v.0.3.SNAPSHOT2520-202

TC:

  1. Open attached project
  2. Run the application
  3. Create new instance of NewsItem and save
  4. Confirm sending an email

AR:

image

There is an exception:

Caused by: org.postgresql.util.PSQLException: ERROR: column "content" is of type oid but expression is of type bytea
2021-02-16 15:21:19.519  WARN 13356 --- [nio-8080-exec-5] eclipselink.logging.all                  : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.7.2-jmix): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: column "content" is of type oid but expression is of type bytea
  Подсказка: You will need to rewrite or cast the expression.
  Позиция: 229
Error Code: 0
Call: INSERT INTO EMAIL_SENDING_ATTACHMENT (ID, CONTENT, CONTENT_FILE, CONTENT_ID, CREATE_TS, CREATED_BY, DELETE_TS, DELETED_BY, DISPOSITION, TEXT_ENCODING, NAME, SYS_TENANT_ID, UPDATE_TS, UPDATED_BY, VERSION, MESSAGE_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	bind => [34747c7b-3641-7a64-3a03-948da2d49fff, [B@1e99d31d, null, logoId, 2021-02-16 15:21:19.517, admin, null, null, inline, null, logo.png, null, 2021-02-16 15:21:19.517, null, 1, 57edb516-6ae4-df35-1552-5afc36f3c955]
Query: InsertObjectQuery(io.jmix.email.entity.SendingAttachment-34747c7b-3641-7a64-3a03-948da2d49fff [new,managed])

sched.zip

QA notes:
Need to recreate a database.

Triggers for Quartz jobs should have an identity

If we create triggers for jobs without identity and Quartz tables are not recreated after each restart
(spring.quartz.jdbc.initialize-schema != always),
we will have a situation when we have a lot of similar triggers for the same job. It happens because Quartz will generate for triggers without identity a new unique identifier each time it starts.
So we need to avoid such situations and give triggers some adequate identity.

Built-in scheduler to delete old emails and attachments

Motivation:
https://www.cuba-platform.ru/discuss/t/otklyuchenie-sledov-zhiznedeyatelnosti-u-cuba-emailer/5396

Customer is complaining about growing size of the database.
95% of the database is consumed by emails and their attachments.

I think we need to have built-in cleaning scheduler out-of-the-box.
Scheduler should hard-delete messages, attachments from DB and associated files from file storage.

Settings:

  • max age of messages
  • some settings to distinguish unimportant messages to be deleted from important business letters that should be stored much longer or forever.

Addressing the problem of different kinds of messages
E.g. a system can send:

  • booking confirmations and notifications - that aren't too important and can be deleted after some time
  • salary documents, invoices - that are important and must be kept for many years or forever

In the simplest implementation we can define two kinds of messages: important or non-important.
Cleaning scheduler has two settings: max age of important messags (or forever), and max age of non-important messages.

Important / nonimportant, or "category" - this attribute can be set via a single Boolean / String attribute, or via set of tags.
Such attribute would be also convenient for categorizing / grouping messages in the browser of sent emails.

"Access denied" after using method processQueuedEmails

Environment
Jmix version: 1.0.0-SNAPSHOT

Description of the bug

  1. Install email add-on
  2. Create new screen
  3. Add button to the screen. Add Click Event containing emailer.processQueuedEmails();
  4. Run application and click on created button
  5. Open Administration -> Email history

ER:
Email history opened in new tab.
AR:
Appears the message "Access denied". The message does not disappear until the user re-logged in.

Application start fails if the Email add-on is used and no file storage is registered

Jmix version: 1.1.0-SNAPSHOT

Steps to reproduce:

  1. Create a project with dependency on the Email add-on and without dependency on any file storage add-on (localfs or awsfs)
  2. Run the app
    AR: App start fails, an exception is thrown:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'email_EmailCleaner': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: No FileStorage beans registered
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.8.jar:5.3.8]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.3.8.jar:5.3.8]
	... 34 common frames omitted
Caused by: java.lang.IllegalStateException: No FileStorage beans registered
	at io.jmix.core.impl.FileStorageLocatorImpl.getDefault(FileStorageLocatorImpl.java:85) ~[jmix-core-1.1.0-SNAPSHOT.jar:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'email_EmailCleaner': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: No FileStorage beans registered

	at io.jmix.email.impl.EmailCleanerImpl.setFileStorage(EmailCleanerImpl.java:57) ~[jmix-email-1.1.0-SNAPSHOT.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_265]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_265]

ER: The app starts successfully

"Send all to admin" does not apply to Cc, Bcc

Environment:
Jmix version: 1.0.0-SNAPSHOT
IntelliJ version: IntelliJ IDEA 2020.3.3 (Community Edition)

Description of the bug

  1. Install email add-on
  2. Add to application.properties
jmix.email.sendAllToAdmin=true
[email protected]
  1. Run application
  2. Send email with address, Cc, Bcc not the same as the adminAddress
  3. Open Administration -> Email History

ER: instead of the indicated ones - the adminAddress.
AR: adminAddress replace only the address, to Cc and Bcc email was sent

Differenet description of datetime fields

Environment
Jmix version: 1.0.0-SNAPSHOT

Description of the bug

  1. Install email add-on
  2. Run application
  3. Go to tab Administration -> Email History

AR:
At the right panel the following fields are used: Created at, Sending Date, Last attempt time.
ER:
field names are reduced to a single form. Example: Creation date, Sending date, Last attempt date or didn't change "Created at", and use Sending date, Last attempt date or Sending time, Last attempt time

Remove a dependency to fsfilestorage

Email addon should not have a dependency to specific filestorage implementation. Users will add a dependency to required filestorage (local filesystem, AWS, etc.) in their projects.
Check that application with the email addon and without any filestorage addon can be started.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.