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");
}
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;
}
Aggregations