Search in sources :

Example 1 with EmailAddressRepository

use of com.axelor.apps.message.db.repo.EmailAddressRepository in project axelor-open-suite by axelor.

the class MailServiceMessageImpl method resolve.

@Override
public Model resolve(String email) {
    final EmailAddressRepository addresses = Beans.get(EmailAddressRepository.class);
    final EmailAddress address = addresses.all().filter("self.address = ?1", email).fetchOne();
    if (address != null) {
        return address;
    }
    return super.resolve(email);
}
Also used : EmailAddressRepository(com.axelor.apps.message.db.repo.EmailAddressRepository) EmailAddress(com.axelor.apps.message.db.EmailAddress)

Example 2 with EmailAddressRepository

use of com.axelor.apps.message.db.repo.EmailAddressRepository in project axelor-open-suite by axelor.

the class TemplateMessageServiceImpl method getEmailAddress.

protected EmailAddress getEmailAddress(String recipient) {
    if (Strings.isNullOrEmpty(recipient)) {
        return null;
    }
    EmailAddressRepository emailAddressRepo = Beans.get(EmailAddressRepository.class);
    EmailAddress emailAddress = emailAddressRepo.findByAddress(recipient);
    if (emailAddress == null) {
        Map<String, Object> values = new HashMap<>();
        values.put("address", recipient);
        emailAddress = emailAddressRepo.create(values);
    }
    return emailAddress;
}
Also used : HashMap(java.util.HashMap) EmailAddressRepository(com.axelor.apps.message.db.repo.EmailAddressRepository) EmailAddress(com.axelor.apps.message.db.EmailAddress)

Aggregations

EmailAddress (com.axelor.apps.message.db.EmailAddress)2 EmailAddressRepository (com.axelor.apps.message.db.repo.EmailAddressRepository)2 HashMap (java.util.HashMap)1