19 package org.turro.students.mail;
21 import java.net.URLEncoder;
22 import java.util.HashMap;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.apache.commons.mail.EmailException;
26 import org.turro.action.Actions;
27 import org.turro.action.LinkType;
28 import org.turro.action.MailSenders;
29 import org.turro.action.queue.NotificationCategory;
30 import org.turro.assistant.Assistant;
31 import org.turro.assistant.AssistantSet;
32 import org.turro.auth.Authentication;
33 import org.turro.elephant.context.Application;
34 import org.turro.elephant.context.ElephantContext;
35 import org.turro.elephant.context.IConstructor;
36 import org.turro.elephant.security.IUser;
37 import org.turro.mail.message.MailMessageTemplate;
38 import org.turro.mail.provider.MailProviders;
39 import org.turro.mail.queue.GenericElephantNotification;
40 import org.turro.mail.queue.QueueManager;
41 import org.turro.marker.ElephantMarker;
42 import org.turro.path.Path;
43 import org.turro.plugin.contacts.IContact;
44 import org.turro.students.command.StudentsEntityInfo;
45 import org.turro.students.db.StudentsPU;
46 import org.turro.students.entities.Challenge;
47 import org.turro.students.entities.Response;
48 import org.turro.students.wrappers.ChallengeWrapper;
75 public void send(String
template, String reason) {
76 addToQueue(
template, reason);
86 HashMap<String, String> values =
new HashMap<>();
88 values.put(
Actions.REDIR_PAR, URLEncoder.encode(redir,
"UTF-8"));
98 return "{liveref:" + redir +
"}";
101 private void addToQueue(String
template, String reason) {
111 mmt.
addTo(assistant.email, assistant.name);
116 em.
put(
"contact", assistant.contact);
117 em.
put(
"email", assistant.email);
118 em.
put(
"notifier",
this);
120 mmt.
setMessage(em,
template, assistant.contact);
121 qm.
addToQueue(nc, assistant.contact, mmt, reason,
"Students");
123 }
catch (EmailException ex) {
130 return String.format(
"[%s #%d %s] %s",
static String createAction(String email, String redir)
static final String USER_PAR
static IContact getIContact()
IConstructor getConstructor()
static Application getApplication()
void setProcessLiveLinks(boolean processLiveLinks)
void setMessage(ElephantMarker marker, IContact contact)
static MailMessageTemplate of(MailProvider provider)
void setRoot(String root)
Email addTo(String email, String name)
void setSubject(String subject)
MailProvider getProvider(String name)
static MailProviders instance()
static final String GENERIC_NOTIFICATION
NotificationCategory getCategory(String id)
MailItem addToQueue(NotificationCategory category, IContact contact, MailMessage mmt, String reason, String poolName)
boolean contactMayWant(IContact contact, String idCategory)
Object put(Object key, Object value)
static String linkForPath(Path path, IContact contact, LinkType type)
static String getObjectPath(Object object)
abstract void sendNotification()
String createRef(IConstructor constructor, Challenge challenge, IContact contact)
String createRef(IConstructor constructor, String redir)
String create(IConstructor constructor, String redir, String email)
abstract void initMarker(ElephantMarker marker)
String getSubject(String reason)
final IConstructor constructor
abstract AssistantSet getAssistants()
final Challenge challenge
AbstractChallengeNotification(Response response)
String create(IConstructor constructor, Challenge challenge, IContact contact)
AbstractChallengeNotification(Challenge challenge)
void send(String template, String reason)
final IContact loggedContact
static final String CONNECTOR_EMAIL