aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-25 12:34:28 +0300
committerGravatar Vitaly Takmazov2017-12-25 12:34:28 +0300
commitd767b84a27b6864897bbfbd8c9250550975c5d45 (patch)
treef05e153262fbbcd52453d5c32026ed6c3a534bba
parent8956e7566e2bdc80ecbfdabe9c38bfe05d3e124b (diff)
email notifications settings
-rw-r--r--juick-server-core/src/main/java/com/juick/service/EmailService.java2
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java7
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/Settings.java8
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/settings_main.html9
4 files changed, 9 insertions, 17 deletions
diff --git a/juick-server-core/src/main/java/com/juick/service/EmailService.java b/juick-server-core/src/main/java/com/juick/service/EmailService.java
index ec43dcad..369434e7 100644
--- a/juick-server-core/src/main/java/com/juick/service/EmailService.java
+++ b/juick-server-core/src/main/java/com/juick/service/EmailService.java
@@ -26,6 +26,6 @@ public interface EmailService {
boolean verifyAddressByCode(Integer userId, String code);
boolean addVerificationCode(Integer userId, String account, String code);
boolean deleteEmail(Integer userId, String account);
- boolean setSubscriptionHour(Integer userId, String account, String hour);
+ boolean setNotificationsEmail(Integer userId, String account);
List<String> getEmails(Integer userId);
}
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java
index d9e35a00..a8c0595e 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/EmailServiceImpl.java
@@ -68,15 +68,16 @@ public class EmailServiceImpl extends BaseJdbcService implements EmailService {
}
@Override
- public boolean setSubscriptionHour(Integer userId, String account, String hour) {
+ public boolean setNotificationsEmail(Integer userId, String account) {
getJdbcTemplate().update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", userId);
return StringUtils.isNotEmpty(account) && getJdbcTemplate().update(
- "UPDATE emails SET subscr_hour=? WHERE user_id=? AND email=?", hour, userId, account) > 0;
+ "UPDATE emails SET subscr_hour=1 WHERE user_id=? AND email=?", userId, account) > 0;
}
@Transactional(readOnly = true)
@Override
public List<String> getEmails(Integer userId) {
- return getJdbcTemplate().queryForList("SELECT email FROM emails WHERE user_id=?", String.class, userId);
+ return getJdbcTemplate().queryForList("SELECT email FROM emails WHERE user_id=? " +
+ "AND subscr_hour IS NOT NULL", String.class, userId);
}
}
diff --git a/juick-www/src/main/java/com/juick/www/controllers/Settings.java b/juick-www/src/main/java/com/juick/www/controllers/Settings.java
index 64775aec..a2459654 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/Settings.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/Settings.java
@@ -214,11 +214,9 @@ public class Settings {
}
break;
case "email-subscr":
- if (emailService.setSubscriptionHour(visitor.getUid(), request.getParameter("account"),
- request.getParameter("time"))) {
- result = String.format("<p>Saved! Will send to <strong>%s</strong> at <strong>%s:00 GMT</strong>." +
- "</p><p><a href=\"/settings\">Back</a></p>", request.getParameter("account"),
- request.getParameter("time"));
+ if (emailService.setNotificationsEmail(visitor.getUid(), request.getParameter("account"))) {
+ result = String.format("<p>Saved! Will send notifications to <strong>%s</strong>." +
+ "</p><p><a href=\"/settings\">Back</a></p>", request.getParameter("account"));
} else {
result = "<p>Disabled.</p><p><a href=\"/settings\">Back</a></p>";
}
diff --git a/juick-www/src/main/webapp/WEB-INF/views/settings_main.html b/juick-www/src/main/webapp/WEB-INF/views/settings_main.html
index 26539a69..dddf63bb 100644
--- a/juick-www/src/main/webapp/WEB-INF/views/settings_main.html
+++ b/juick-www/src/main/webapp/WEB-INF/views/settings_main.html
@@ -84,7 +84,7 @@
{% if emails is not empty %}
<!--email_off-->
<form action="/settings" method="POST" enctype="multipart/form-data">
- <p>You can receive all your subscriptions by email:<br/>
+ <p>You can receive notifications to email:<br/>
Sent to <select name="account">
<option value="">Disabled</option>
{% for email in emails %}
@@ -92,13 +92,6 @@
{{ email }}
</option>
{% endfor %}
- </select> every day at <select name="time">
- {% for hour in hours %}
- <option value="{{ hour }}" {% if eopts.subscriptionHour == hour %} selected="selected" {%
- endif %}>
- {{ hour }}:00 GMT
- </option>
- {% endfor %}
</select>
<input type="hidden" name="page" value="email-subscr"/>
<input type="submit" value="OK"/></p>