Merge branch 'main' into lang_de
This commit is contained in:
@@ -50,13 +50,13 @@ public class ListMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String addNewModerator(String userEmail) {
|
public String addNewModerator(String userEmail) {
|
||||||
if (!isAllowedToEditMods()) return t("You are not allowed to nominate new mods for {}",list.email());
|
if (!isAllowedToEditMods()) return t("You are not allowed to nominate new mods for {}!",list.email());
|
||||||
User moderator = null;
|
User moderator = null;
|
||||||
try {
|
try {
|
||||||
moderator = User.load(userEmail);
|
moderator = User.load(userEmail);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to load user for {}",userEmail,e);
|
LOG.warn("Failed to load user for {}!",userEmail,e);
|
||||||
return t("Failed to load user for {}",userEmail);
|
return t("Failed to load user for {}!",userEmail);
|
||||||
}
|
}
|
||||||
if (moderator == null) return t("No such user: {}",userEmail);
|
if (moderator == null) return t("No such user: {}",userEmail);
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ public class ListMember {
|
|||||||
try {
|
try {
|
||||||
member = ListMember.load(list,moderator);
|
member = ListMember.load(list,moderator);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to load list member for {}/{}",moderator.email(),list.email(),e);
|
LOG.warn("Failed to load list member for {}/{}!",moderator.email(),list.email(),e);
|
||||||
return t("Failed to load list member for {}/{}",moderator.email(),list.email());
|
return t("Failed to load list member for {}/{}!",moderator.email(),list.email());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (member == null) {
|
if (member == null) {
|
||||||
@@ -146,13 +146,13 @@ public class ListMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String dropMember(String userEmail) {
|
public String dropMember(String userEmail) {
|
||||||
if (!isModerator()) return t("You are not allowed to remove members of {}",list.email());
|
if (!isModerator()) return t("You are not allowed to remove members of {}!",list.email());
|
||||||
User user = null;
|
User user = null;
|
||||||
try {
|
try {
|
||||||
user = User.load(userEmail);
|
user = User.load(userEmail);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to load user for {}",userEmail,e);
|
LOG.warn("Failed to load user for {}!",userEmail,e);
|
||||||
return t("Failed to load user for {}",userEmail);
|
return t("Failed to load user for {}!",userEmail);
|
||||||
}
|
}
|
||||||
if (user == null) return t("No such user: {}",userEmail);
|
if (user == null) return t("No such user: {}",userEmail);
|
||||||
|
|
||||||
@@ -160,30 +160,30 @@ public class ListMember {
|
|||||||
try {
|
try {
|
||||||
member = ListMember.load(list,user);
|
member = ListMember.load(list,user);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to load list member for {}/{}",user.email(),list.email(),e);
|
LOG.warn("Failed to load list member for {}/{}!",user.email(),list.email(),e);
|
||||||
return t("Failed to load list member for {}/{}",user.email(),list.email());
|
return t("Failed to load list member for {}/{}!",user.email(),list.email());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (member == null) return t("{} is no member of {}",user.email(),list.email());
|
if (member == null) return t("{} is no member of {}!",user.email(),list.email());
|
||||||
if (member.isOwner()) return t("You are not allowed to remvoe the list owner!");
|
if (member.isOwner()) return t("You are not allowed to remove the list owner!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
member.unsubscribe();
|
member.unsubscribe();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to un-subscribe {} from {}",user.email(),list.email(),e);
|
LOG.warn("Failed to un-subscribe {} from {}!",user.email(),list.email(),e);
|
||||||
return t("Failed to un-subscribe {} from {}",user.email(),list.email());
|
return t("Failed to un-subscribe {} from {}!",user.email(),list.email());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String dropModerator(String userEmail) {
|
public String dropModerator(String userEmail) {
|
||||||
if (!isAllowedToEditMods()) return t("You are not allowed to edit mods of {}",list.email());
|
if (!isAllowedToEditMods()) return t("You are not allowed to edit mods of {}!",list.email());
|
||||||
User moderator = null;
|
User moderator = null;
|
||||||
try {
|
try {
|
||||||
moderator = User.load(userEmail);
|
moderator = User.load(userEmail);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to load user for {}",userEmail,e);
|
LOG.warn("Failed to load user for {}!",userEmail,e);
|
||||||
return t("Failed to load user for {}",userEmail);
|
return t("Failed to load user for {}!",userEmail);
|
||||||
}
|
}
|
||||||
if (moderator == null) return t("No such user: {}",userEmail);
|
if (moderator == null) return t("No such user: {}",userEmail);
|
||||||
|
|
||||||
@@ -191,8 +191,8 @@ public class ListMember {
|
|||||||
try {
|
try {
|
||||||
member = ListMember.load(list,moderator);
|
member = ListMember.load(list,moderator);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to load list member for {}/{}",moderator.email(),list.email(),e);
|
LOG.warn("Failed to load list member for {}/{}!",moderator.email(),list.email(),e);
|
||||||
return t("Failed to load list member for {}/{}",moderator.email(),list.email());
|
return t("Failed to load list member for {}/{}!",moderator.email(),list.email());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (member == null) {
|
if (member == null) {
|
||||||
@@ -201,8 +201,8 @@ public class ListMember {
|
|||||||
member.setState(Util.unset(member.state,STATE_MODERATOR));
|
member.setState(Util.unset(member.state,STATE_MODERATOR));
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Failed to make {} a subscriber of {}",moderator.email(),list.email(),e);
|
LOG.warn("Failed to make {} a subscriber of {}!",moderator.email(),list.email(),e);
|
||||||
return t("Failed to make {} a subscriber of {}",moderator.email(),list.email());
|
return t("Failed to make {} a subscriber of {}!",moderator.email(),list.email());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -392,10 +392,10 @@ public class ListMember {
|
|||||||
*/
|
*/
|
||||||
public String stateText() {
|
public String stateText() {
|
||||||
var words = new ArrayList<String>();
|
var words = new ArrayList<String>();
|
||||||
if (isAwaiting()) words.add("awaiting confirmation");
|
if (isAwaiting()) words.add(t("awaiting confirmation"));
|
||||||
if (isModerator()) words.add("moderator");
|
if (isModerator()) words.add(t("moderator"));
|
||||||
if (isOwner()) words.add("owner");
|
if (isOwner()) words.add(t("owner"));
|
||||||
if (isSubscriber()) words.add("subscriber");
|
if (isSubscriber()) words.add(t("subscriber"));
|
||||||
return String.join(", ",words);
|
return String.join(", ",words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|||||||
var member = ListMember.load(this,user);
|
var member = ListMember.load(this,user);
|
||||||
return member.hasState(ListMember.STATE_OWNER|ListMember.STATE_SUBSCRIBER); // owners may subscribe their own mailing lists
|
return member.hasState(ListMember.STATE_OWNER|ListMember.STATE_SUBSCRIBER); // owners may subscribe their own mailing lists
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Was not able to load ListMember: ",e);
|
LOG.warn("Was not able to load ListMember:",e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|||||||
ml.lastError = rs.getString(LAST_ERROR);
|
ml.lastError = rs.getString(LAST_ERROR);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.debug("Failed to load MailingList: ",e);
|
LOG.debug("Failed to load MailingList:",e);
|
||||||
}
|
}
|
||||||
return ml;
|
return ml;
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,7 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|||||||
.compile().exec();
|
.compile().exec();
|
||||||
while (rs.next()) list.add(MailingList.from(rs));
|
while (rs.next()) list.add(MailingList.from(rs));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.debug("Failed to load MailingLists: ",e);
|
LOG.debug("Failed to load MailingLists:",e);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -671,11 +671,11 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|||||||
try {
|
try {
|
||||||
var config = Configuration.instance();
|
var config = Configuration.instance();
|
||||||
var url = new StringBuilder(config.baseUrl()).append("/web/confirm?token=").append(member.token()).toString();
|
var url = new StringBuilder(config.baseUrl()).append("/web/confirm?token=").append(member.token()).toString();
|
||||||
var subject = t("[{}] Please confirm your list subscription",name());
|
var subject = t("[{}] Please confirm your list subscription!",name());
|
||||||
var text = template.add(URL,url).add(LIST_NAME,name()).render();
|
var text = template.add(URL,url).add(LIST_NAME,name()).render();
|
||||||
smtp.send(email(),name(),user.email(),subject,text);
|
smtp.send(email(),name(),user.email(),subject,text);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new MessagingException(t("Failed to send email to {}",user.email()),e);
|
throw new MessagingException(t("Failed to send email to {}!",user.email()),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,7 +711,7 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|||||||
* @throws UnsupportedEncodingException
|
* @throws UnsupportedEncodingException
|
||||||
*/
|
*/
|
||||||
public void test(User user) throws MessagingException, UnsupportedEncodingException {
|
public void test(User user) throws MessagingException, UnsupportedEncodingException {
|
||||||
var subject = t("[{}]: test mail",name());
|
var subject = t("[{}] test mail",name());
|
||||||
var text = "If you received this mail, the SMTP settings of your mailing list are correct.";
|
var text = "If you received this mail, the SMTP settings of your mailing list are correct.";
|
||||||
smtp.login().send(email(),name(),user.email(),subject,text);
|
smtp.login().send(email(),name(),user.email(),subject,text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ public class User {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<String,String> safeMap(){
|
public Map<String,String> safeMap(){
|
||||||
return Map.of(NAME,name,EMAIL,email,PERMISSIONS,permissionList(),PASSWORD,hashedPassword() == null ? "no" : "yes");
|
return Map.of(NAME,name,EMAIL,email,PERMISSIONS,permissionList(),PASSWORD,t(hashedPassword() == null ? "no" : "yes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package de.srsoftware.widerhall.mail;
|
|||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
|
|
||||||
public interface ProblemListener {
|
public interface ProblemListener {
|
||||||
public void onImapException(MessagingException e);
|
|
||||||
|
|
||||||
public void clearProblems();
|
public void clearProblems();
|
||||||
|
public void onImapException(MessagingException e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class SmtpClient {
|
|||||||
MimeMultipart multipart = new MimeMultipart();
|
MimeMultipart multipart = new MimeMultipart();
|
||||||
if (forwardAsAttachment){
|
if (forwardAsAttachment){
|
||||||
MimeBodyPart bodyPart = new MimeBodyPart();
|
MimeBodyPart bodyPart = new MimeBodyPart();
|
||||||
bodyPart.setText("Find the forwarded message in the attachment(s)!\n");
|
bodyPart.setText(t("Find the forwarded message in the attachment(s)!\n"));
|
||||||
multipart.addBodyPart(bodyPart);
|
multipart.addBodyPart(bodyPart);
|
||||||
|
|
||||||
// create another body part to contain the message to be forwarded
|
// create another body part to contain the message to be forwarded
|
||||||
@@ -109,9 +109,9 @@ public class SmtpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void send(Message message) throws MessagingException {
|
public void send(Message message) throws MessagingException {
|
||||||
LOG.debug("Versende Mail…");
|
LOG.debug("sending mail…");
|
||||||
Transport.send(message,username,password);
|
Transport.send(message,username,password);
|
||||||
LOG.debug("…versendet");
|
LOG.debug("…sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(String senderAdress, String senderName, String receivers, String subject, String content) throws MessagingException, UnsupportedEncodingException {
|
public void send(String senderAdress, String senderName, String receivers, String subject, String content) throws MessagingException, UnsupportedEncodingException {
|
||||||
|
|||||||
@@ -47,17 +47,17 @@ public class Rest extends HttpServlet {
|
|||||||
private static final String SUCCESS = "success";
|
private static final String SUCCESS = "success";
|
||||||
|
|
||||||
private Map addPermission(String userEmail, String permissions) {
|
private Map addPermission(String userEmail, String permissions) {
|
||||||
if (userEmail == null || userEmail.isBlank()) return Map.of(ERROR,"missing user email address!");
|
if (userEmail == null || userEmail.isBlank()) return Map.of(ERROR,t("missing user email address!"));
|
||||||
try {
|
try {
|
||||||
int perm = Integer.parseInt(permissions);
|
int perm = Integer.parseInt(permissions);
|
||||||
var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null);
|
var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null);
|
||||||
if (user == null) return Map.of(ERROR,t("Failed to load user for address {}",userEmail));
|
if (user == null) return Map.of(ERROR,t("Failed to load user for address {}!",userEmail));
|
||||||
user.addPermission(perm);
|
user.addPermission(perm);
|
||||||
} catch (NumberFormatException nfe){
|
} catch (NumberFormatException nfe){
|
||||||
return Map.of(ERROR,"no valid permissions provided!");
|
return Map.of(ERROR,"no valid permissions provided!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.debug("Failed to load user for address {}",userEmail,e);
|
LOG.debug("Failed to load user for address {}!",userEmail,e);
|
||||||
return Map.of(ERROR,t("Failed to load user for address {}",userEmail));
|
return Map.of(ERROR,t("Failed to load user for address {}!",userEmail));
|
||||||
}
|
}
|
||||||
return Map.of(SUCCESS,"Updated user permissions");
|
return Map.of(SUCCESS,"Updated user permissions");
|
||||||
}
|
}
|
||||||
@@ -141,13 +141,13 @@ public class Rest extends HttpServlet {
|
|||||||
try {
|
try {
|
||||||
int perm = Integer.parseInt(permissions);
|
int perm = Integer.parseInt(permissions);
|
||||||
var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null);
|
var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null);
|
||||||
if (user == null) return Map.of(ERROR,t("Failed to load user for address {}",userEmail));
|
if (user == null) return Map.of(ERROR,t("Failed to load user for address {}!",userEmail));
|
||||||
user.dropPermission(perm);
|
user.dropPermission(perm);
|
||||||
} catch (NumberFormatException nfe){
|
} catch (NumberFormatException nfe){
|
||||||
return Map.of(ERROR,"no valid permissions provided!");
|
return Map.of(ERROR,"no valid permissions provided!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.debug("Failed to load user for address {}",userEmail,e);
|
LOG.debug("Failed to load user for address {}!",userEmail,e);
|
||||||
return Map.of(ERROR,t("Failed to load user for address {}",userEmail));
|
return Map.of(ERROR,t("Failed to load user for address {}!",userEmail));
|
||||||
}
|
}
|
||||||
return Map.of(SUCCESS,t("Updated user permissions"));
|
return Map.of(SUCCESS,t("Updated user permissions"));
|
||||||
}
|
}
|
||||||
@@ -157,10 +157,10 @@ public class Rest extends HttpServlet {
|
|||||||
if (!list.mayBeAlteredBy(user)) Map.of(ERROR,t("You are not allowed to edit '{}'",list.email()));
|
if (!list.mayBeAlteredBy(user)) Map.of(ERROR,t("You are not allowed to edit '{}'",list.email()));
|
||||||
try {
|
try {
|
||||||
list.enable(enable);
|
list.enable(enable);
|
||||||
return Map.of(SUCCESS,t("Mailing list '{}' was {}!",list.email(),enable ? "enabled" : "disabled"));
|
return Map.of(SUCCESS,t("Mailing list '{}' was {}!",list.email(),t(enable ? "enabled" : "disabled")));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.error("Failed to enable/disable mailing list: ",e);
|
LOG.error("Failed to enable/disable mailing list:",e);
|
||||||
return Map.of(ERROR,t("Failed to update list '{}'",list.email()));
|
return Map.of(ERROR,t("Failed to update list '{}'!",list.email()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ public class Rest extends HttpServlet {
|
|||||||
json.put("users", (user.hashPermission(User.PERMISSION_ADMIN) ? User.loadAll() : List.of(user)).stream().map(User::safeMap).toList());
|
json.put("users", (user.hashPermission(User.PERMISSION_ADMIN) ? User.loadAll() : List.of(user)).stream().map(User::safeMap).toList());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.debug("Failed to load user list:",e);
|
LOG.debug("Failed to load user list:",e);
|
||||||
json.put(ERROR,"failed to load user list");
|
json.put(ERROR,t("failed to load user list"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LIST_MODERATED:
|
case LIST_MODERATED:
|
||||||
@@ -203,7 +203,7 @@ public class Rest extends HttpServlet {
|
|||||||
json.put("lists", MailingList.subscribable().stream().map(MailingList::minimalMap).toList());
|
json.put("lists", MailingList.subscribable().stream().map(MailingList::minimalMap).toList());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
json.put(ERROR,"Not logged in!");
|
json.put(ERROR,t("Not logged in!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -270,19 +270,19 @@ public class Rest extends HttpServlet {
|
|||||||
case USER_ADD_PERMISSION:
|
case USER_ADD_PERMISSION:
|
||||||
if (user.hashPermission(User.PERMISSION_ADMIN)){
|
if (user.hashPermission(User.PERMISSION_ADMIN)){
|
||||||
json.putAll(addPermission(userEmail,permissions));
|
json.putAll(addPermission(userEmail,permissions));
|
||||||
} else json.put(ERROR,"You are not allowed to alter user permissions!");
|
} else json.put(ERROR,t("You are not allowed to alter user permissions!"));
|
||||||
break;
|
break;
|
||||||
case USER_DROP_PERMISSION:
|
case USER_DROP_PERMISSION:
|
||||||
if (user.hashPermission(User.PERMISSION_ADMIN)){
|
if (user.hashPermission(User.PERMISSION_ADMIN)){
|
||||||
json.putAll(dropPermission(userEmail,permissions));
|
json.putAll(dropPermission(userEmail,permissions));
|
||||||
} else json.put(ERROR,"You are not allowed to alter user permissions!");
|
} else json.put(ERROR,t("You are not allowed to alter user permissions!"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
json.put(ERROR,t("No handler for path '{}'!",path));
|
json.put(ERROR,t("No handler for path '{}'!",path));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
json.put(ERROR,"Not logged in!");
|
json.put(ERROR,t("Not logged in!"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resp.setContentType("application/json");
|
resp.setContentType("application/json");
|
||||||
@@ -298,9 +298,9 @@ public class Rest extends HttpServlet {
|
|||||||
if (!list.mayBeAlteredBy(user)) Map.of(ERROR,t("You are not allowed to edit '{}'",list.email()));
|
if (!list.mayBeAlteredBy(user)) Map.of(ERROR,t("You are not allowed to edit '{}'",list.email()));
|
||||||
try {
|
try {
|
||||||
list.hide(hide);
|
list.hide(hide);
|
||||||
return Map.of(SUCCESS,t("Mailing list '{}' was {}!",list.email(),hide ? "hidden" : "made public"));
|
return Map.of(SUCCESS,t("Mailing list '{}' was {}!",list.email(),t(hide ? "hidden" : "made public")));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.error("Failed to (un)hide mailing list: ",e);
|
LOG.error("Failed to (un)hide mailing list:",e);
|
||||||
return Map.of(ERROR,t("Failed to update list '{}'",list.email()));
|
return Map.of(ERROR,t("Failed to update list '{}'",list.email()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ public class Rest extends HttpServlet {
|
|||||||
LOG.warn("Failed to load list member for {}/{}",user.email(),list.email(),e);
|
LOG.warn("Failed to load list member for {}/{}",user.email(),list.email(),e);
|
||||||
return Map.of(ERROR,t("Failed to load list member for {}/{}",user.email(),list.email()));
|
return Map.of(ERROR,t("Failed to load list member for {}/{}",user.email(),list.email()));
|
||||||
}
|
}
|
||||||
if (moderator == null) return Map.of(ERROR,t("{} is not a member of {}",user.email(),list.email()));
|
if (moderator == null) return Map.of(ERROR,t("{} is not a member of {}!",user.email(),list.email()));
|
||||||
|
|
||||||
var error = moderator.addNewModerator(userEmail);
|
var error = moderator.addNewModerator(userEmail);
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ public class Rest extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map listDetail(MailingList list, User user) {
|
private Map listDetail(MailingList list, User user) {
|
||||||
if (list == null) return Map.of(ERROR,"no list email provided!");
|
if (list == null) return Map.of(ERROR,t("no list email provided!"));
|
||||||
var map = new HashMap<>();
|
var map = new HashMap<>();
|
||||||
if (list.hasState(MailingList.STATE_FORWARD_FROM)) map.put(KEY_FORWARD_FROM,true);
|
if (list.hasState(MailingList.STATE_FORWARD_FROM)) map.put(KEY_FORWARD_FROM,true);
|
||||||
if (list.hasState(MailingList.STATE_FORWARD_ATTACHED)) map.put(KEY_FORWARD_ATTACHED,true);
|
if (list.hasState(MailingList.STATE_FORWARD_ATTACHED)) map.put(KEY_FORWARD_ATTACHED,true);
|
||||||
@@ -366,8 +366,8 @@ public class Rest extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> listMembers(MailingList list, User user) {
|
private Map<String, Object> listMembers(MailingList list, User user) {
|
||||||
if (list == null) return Map.of(ERROR,"no list email provided!");
|
if (list == null) return Map.of(ERROR,t("no list email provided!"));
|
||||||
if (!list.membersMayBeListedBy(user)) Map.of(ERROR,t("You are not allowed to list members of '{}'",list.email()));
|
if (!list.membersMayBeListedBy(user)) Map.of(ERROR,t("You are not allowed to list members of '{}'!",list.email()));
|
||||||
try {
|
try {
|
||||||
var members = list.members()
|
var members = list.members()
|
||||||
.sorted((m1,m2)->m1.user().name().compareTo(m2.user().name()))
|
.sorted((m1,m2)->m1.user().name().compareTo(m2.user().name()))
|
||||||
@@ -376,19 +376,19 @@ public class Rest extends HttpServlet {
|
|||||||
return Map.of(MEMBERS,members,LIST,list.minimalMap());
|
return Map.of(MEMBERS,members,LIST,list.minimalMap());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.error("Failed to load member list: ",e);
|
LOG.error("Failed to load member list: ",e);
|
||||||
return Map.of(ERROR,t("Failed to load member list '{}'",list.email()));
|
return Map.of(ERROR,t("Failed to load member list '{}'!",list.email()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map testList(MailingList list, User user) {
|
private Map testList(MailingList list, User user) {
|
||||||
if (list == null) return Map.of(ERROR,"no list email provided!");
|
if (list == null) return Map.of(ERROR,t("no list email provided!"));
|
||||||
if (!list.mayBeTestedBy(user)) Map.of(ERROR,t("You are not allowed to test '{}'",list.email()));
|
if (!list.mayBeTestedBy(user)) Map.of(ERROR,t("You are not allowed to test '{}'!",list.email()));
|
||||||
try {
|
try {
|
||||||
list.test(user);
|
list.test(user);
|
||||||
return Map.of(SUCCESS,t("Sent test email to {}",user.email()));
|
return Map.of(SUCCESS,t("Sent test email to {}",user.email()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Failed to send test email",e);
|
LOG.warn("Failed to send test email",e);
|
||||||
return Map.of(ERROR,t("Failed to send test email to {}",user.email()));
|
return Map.of(ERROR,t("Failed to send test email to {}!",user.email()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public abstract class TemplateServlet extends HttpServlet {
|
|||||||
resp.getWriter().println(template.render());
|
resp.getWriter().println(template.render());
|
||||||
return null;
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return t("Failed to load template '{}'",path);
|
return t("Failed to load template '{}'!",path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t("No template for path '{}'!",path);
|
return t("No template for path '{}'!",path);
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public class Web extends TemplateServlet {
|
|||||||
|
|
||||||
return loadTemplate(INDEX,Map.of(USER,listMember.user().safeMap(),NOTES,"Confirmed list subscription!"),resp);
|
return loadTemplate(INDEX,Map.of(USER,listMember.user().safeMap(),NOTES,"Confirmed list subscription!"),resp);
|
||||||
}
|
}
|
||||||
return t("Unknown user or token");
|
return t("Unknown user or token!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug("Failed to confirm list membership:",e);
|
LOG.debug("Failed to confirm list membership:",e);
|
||||||
return t("Confirmation of list membership failed!");
|
return t("Confirmation of list membership failed!");
|
||||||
@@ -260,7 +260,7 @@ public class Web extends TemplateServlet {
|
|||||||
return loadTemplate(ADMIN,data,resp);
|
return loadTemplate(ADMIN,data,resp);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOG.warn("Editing list {} by {} failed",list.email(),user.email(),e);
|
LOG.warn("Editing list {} by {} failed",list.email(),user.email(),e);
|
||||||
return t("Editing list {} by {} failed",list.email(),user.email());
|
return t("Editing list {} by {} failed!",list.email(),user.email());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ public class Web extends TemplateServlet {
|
|||||||
return post(req,resp);
|
return post(req,resp);
|
||||||
case RELOAD:
|
case RELOAD:
|
||||||
loadTemplates();
|
loadTemplates();
|
||||||
data.put(NOTES,t("Templates have been reloaded"));
|
data.put(NOTES,t("Templates have been reloaded!"));
|
||||||
path = INDEX;
|
path = INDEX;
|
||||||
case CSS:
|
case CSS:
|
||||||
case INDEX:
|
case INDEX:
|
||||||
@@ -402,7 +402,7 @@ public class Web extends TemplateServlet {
|
|||||||
|
|
||||||
if (!error && !list.mayBeAlteredBy(user)) {
|
if (!error && !list.mayBeAlteredBy(user)) {
|
||||||
error = true;
|
error = true;
|
||||||
data.put(ERROR,t("You are not alter settings of this list!"));
|
data.put(ERROR,t("You are not allowed to alter settings of this list!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error){
|
if (!error){
|
||||||
@@ -463,9 +463,9 @@ public class Web extends TemplateServlet {
|
|||||||
if (email == null || email.isBlank() ||
|
if (email == null || email.isBlank() ||
|
||||||
name == null || name.isBlank() ||
|
name == null || name.isBlank() ||
|
||||||
pass == null || pass.isBlank() ||
|
pass == null || pass.isBlank() ||
|
||||||
pass_repeat == null || pass_repeat.isBlank()) return loadTemplate(REGISTER,Map.of(ERROR,"Fill all fields, please!",NAME,name,EMAIL,email),resp);
|
pass_repeat == null || pass_repeat.isBlank()) return loadTemplate(REGISTER,Map.of(ERROR,t"Fill all fields, please!"),NAME,name,EMAIL,email),resp);
|
||||||
if (!pass.equals(pass_repeat)) return loadTemplate(REGISTER,Map.of(ERROR,"Passwords do not match!",NAME,name,EMAIL,email),resp);
|
if (!pass.equals(pass_repeat)) return loadTemplate(REGISTER,Map.of(ERROR,t("Passwords do not match!"),NAME,name,EMAIL,email),resp);
|
||||||
if (Util.simplePassword(pass)) return loadTemplate(REGISTER,Map.of(ERROR,"Password to short or to simple!",NAME,name,EMAIL,email),resp);
|
if (Util.simplePassword(pass)) return loadTemplate(REGISTER,Map.of(ERROR,t("Password to short or to simple!"),NAME,name,EMAIL,email),resp);
|
||||||
|
|
||||||
var firstUser = false;
|
var firstUser = false;
|
||||||
try {
|
try {
|
||||||
@@ -565,12 +565,12 @@ public class Web extends TemplateServlet {
|
|||||||
data.put(EMAIL,email);
|
data.put(EMAIL,email);
|
||||||
if (user != null) data.put(USER,user.safeMap());
|
if (user != null) data.put(USER,user.safeMap());
|
||||||
if (list == null){
|
if (list == null){
|
||||||
data.put(ERROR,"No list provided by form data!");
|
data.put(ERROR,t("No list provided by form data!"));
|
||||||
return loadTemplate(UNSUBSCRIBE,data,resp);
|
return loadTemplate(UNSUBSCRIBE,data,resp);
|
||||||
} else data.put(LIST,list.email());
|
} else data.put(LIST,list.email());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
if (email == null || email.isBlank()) {
|
if (email == null || email.isBlank()) {
|
||||||
data.put(ERROR, "Email is required for list un-subscription!");
|
data.put(ERROR, t("Email is required for list un-subscription!"));
|
||||||
return loadTemplate(UNSUBSCRIBE, data, resp);
|
return loadTemplate(UNSUBSCRIBE, data, resp);
|
||||||
}
|
}
|
||||||
var pass = req.getParameter(PASSWORD);
|
var pass = req.getParameter(PASSWORD);
|
||||||
@@ -581,7 +581,7 @@ public class Web extends TemplateServlet {
|
|||||||
req.getSession().setAttribute(USER,user);
|
req.getSession().setAttribute(USER,user);
|
||||||
data.put(USER,user.safeMap());
|
data.put(USER,user.safeMap());
|
||||||
} catch (InvalidKeyException | SQLException e) {
|
} catch (InvalidKeyException | SQLException e) {
|
||||||
data.put(ERROR,"Invalid email/password combination!");
|
data.put(ERROR,t("Invalid email/password combination!"));
|
||||||
return loadTemplate(UNSUBSCRIBE,data,resp);
|
return loadTemplate(UNSUBSCRIBE,data,resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user