Mercurial Hosting > nabble
comparison src/nabble/view/web/mailing_list/Unsubscribe.java @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children | 18cf4872fd7f |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7ecd1a4ef557 |
---|---|
1 | |
2 package nabble.view.web.mailing_list; | |
3 | |
4 import fschmidt.util.mail.Mail; | |
5 import nabble.model.MailingList; | |
6 import nabble.model.ModelHome; | |
7 import nabble.model.Node; | |
8 import nabble.model.User; | |
9 import nabble.view.lib.Jtp; | |
10 import org.slf4j.Logger; | |
11 import org.slf4j.LoggerFactory; | |
12 | |
13 import javax.servlet.ServletException; | |
14 import javax.servlet.http.HttpServlet; | |
15 import javax.servlet.http.HttpServletRequest; | |
16 import javax.servlet.http.HttpServletResponse; | |
17 import java.io.IOException; | |
18 | |
19 | |
20 public final class Unsubscribe extends HttpServlet { | |
21 | |
22 private static final Logger logger = LoggerFactory.getLogger(Unsubscribe.class); | |
23 | |
24 protected void service(HttpServletRequest request,HttpServletResponse response) | |
25 throws ServletException, IOException | |
26 { | |
27 User user = Jtp.getUser(request,response); | |
28 if( user==null ) { | |
29 Jtp.login("You must login to be able to unsubscribe from a list.",request,response); | |
30 return; | |
31 } | |
32 Node forum = Jtp.getSiteNotNull(request).getNode(Long.parseLong(request.getParameter("forum"))); | |
33 MailingList mailingList = forum.getAssociatedMailingList(); | |
34 Mail unsubscribeMail = mailingList.unsubscribeMail(user); | |
35 ModelHome.send(unsubscribeMail); | |
36 logger.info("unsubscription request from "+user.getEmail()+" to "+mailingList.getListAddress()); | |
37 response.sendRedirect("Unsubscribe2.jtp?forum="+forum.getId()); | |
38 } | |
39 } | |
40 |