From d767b84a27b6864897bbfbd8c9250550975c5d45 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 25 Dec 2017 12:34:28 +0300 Subject: email notifications settings --- .../src/main/java/com/juick/service/EmailService.java | 2 +- .../src/main/java/com/juick/service/EmailServiceImpl.java | 7 ++++--- juick-www/src/main/java/com/juick/www/controllers/Settings.java | 8 +++----- juick-www/src/main/webapp/WEB-INF/views/settings_main.html | 9 +-------- 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 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 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("

Saved! Will send to %s at %s:00 GMT." + - "

Back

", request.getParameter("account"), - request.getParameter("time")); + if (emailService.setNotificationsEmail(visitor.getUid(), request.getParameter("account"))) { + result = String.format("

Saved! Will send notifications to %s." + + "

Back

", request.getParameter("account")); } else { result = "

Disabled.

Back

"; } 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 %}
-

You can receive all your subscriptions by email:
+

You can receive notifications to email:
Sent to every day at

-- cgit v1.2.3