Search in sources :

Example 21 with DBMailLight

use of org.olat.core.util.mail.model.DBMailLight in project openolat by klemens.

the class MailBoxExtension method deleteUserData.

@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
    // set as deleted all recipients
    log.info("Delete intern messages");
    Collection<DBMailLight> inbox = new HashSet<DBMailLight>(mailManager.getInbox(identity, null, Boolean.FALSE, null, 0, 0));
    for (DBMailLight inMail : inbox) {
        mailManager.delete(inMail, identity, true);
    }
    Collection<DBMailLight> outbox = new HashSet<DBMailLight>(mailManager.getOutbox(identity, 0, 0, false));
    for (DBMailLight outMail : outbox) {
        mailManager.delete(outMail, identity, true);
    }
    log.info("Delete " + inbox.size() + " messages in INBOX and " + outbox.size() + " in OUTBOX");
}
Also used : DBMailLight(org.olat.core.util.mail.model.DBMailLight) HashSet(java.util.HashSet)

Example 22 with DBMailLight

use of org.olat.core.util.mail.model.DBMailLight in project openolat by klemens.

the class MailNotificationsHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    if (!mailModule.isInternSystem()) {
        return notificationsManager.getNoSubscriptionInfo();
    }
    String realMail = subscriber.getIdentity().getUser().getPreferences().getReceiveRealMail();
    if ("true".equals(realMail)) {
        // receive real e-mails
        return notificationsManager.getNoSubscriptionInfo();
    } else if (!StringHelper.containsNonWhitespace(realMail) && mailModule.isReceiveRealMailUserDefaultSetting()) {
        // user has no settings, check the default setting
        return notificationsManager.getNoSubscriptionInfo();
    }
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();
    // can't be loaded when already deleted
    if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
        try {
            List<DBMailLight> inbox = mailManager.getInbox(subscriber.getIdentity(), Boolean.TRUE, Boolean.FALSE, compareDate, 0, -1);
            if (!inbox.isEmpty()) {
                Translator translator = Util.createPackageTranslator(MailModule.class, locale);
                si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(translator.translate("mail.notification.type"), "o_co_icon"), null);
                for (DBMailLight mail : inbox) {
                    String subject = mail.getSubject();
                    String businessPath = "[Inbox:0][Inbox:0][DBMail:" + mail.getKey() + "]";
                    String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                    SubscriptionListItem subListItem = new SubscriptionListItem(subject, urlToSend, businessPath, mail.getCreationDate(), "o_co_icon");
                    si.addSubscriptionListItem(subListItem);
                }
            }
        } catch (Exception ex) {
            logError("", ex);
        }
    }
    if (si == null) {
        si = notificationsManager.getNoSubscriptionInfo();
    }
    return si;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Date(java.util.Date) DBMailLight(org.olat.core.util.mail.model.DBMailLight)

Aggregations

DBMailLight (org.olat.core.util.mail.model.DBMailLight)22 MailerResult (org.olat.core.util.mail.MailerResult)14 Test (org.junit.Test)12 Identity (org.olat.core.id.Identity)12 MailBundle (org.olat.core.util.mail.MailBundle)12 HashSet (java.util.HashSet)6 ContactList (org.olat.core.util.mail.ContactList)4 DBMailRecipient (org.olat.core.util.mail.model.DBMailRecipient)4 ArrayList (java.util.ArrayList)2 BitSet (java.util.BitSet)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 Publisher (org.olat.core.commons.services.notifications.Publisher)2 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)2 ShortName (org.olat.core.gui.ShortName)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2