Skip to content

Commit

Permalink
Make public static methods contingent on setting PUSH_API_KEY/PUSH_AP…
Browse files Browse the repository at this point in the history
…I_URL. Make inner sendPush() method package scope.
  • Loading branch information
JymDyerIBI committed Aug 31, 2023
1 parent be241ed commit 38660e6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class NotificationUtils {
* @param templateData template data
*/
public static String sendPush(OtpUser otpUser, String textTemplate, Object templateData) {
// If Push API config properties aren't set, do nothing.
if (PUSH_API_KEY.equals(null) || PUSH_API_URL.equals(null)) return null;
try {
String body = TemplateUtils.renderTemplate(textTemplate, templateData);
String toUser = otpUser.email;
Expand All @@ -67,7 +69,7 @@ public static String sendPush(OtpUser otpUser, String textTemplate, Object templ
* @param body message body
* @return "OK" if message was successful (null otherwise)
*/
public static String sendPush(String toUser, String body) {
static String sendPush(String toUser, String body) {
try {
var jsonBody = "{\"user\":\"" + toUser + "\",\"message\":\"" + body + "\"}";
Map<String, String> headers = Map.of("Accept", "application/json");
Expand Down Expand Up @@ -280,8 +282,11 @@ public static boolean sendEmailViaSparkpost(
* to obtain this value, as the <code>publish</code> endpoint returns success even for zero devices.
*
* @param toUser email address of user that devices are indexed by
* @return number of devices registered, <code>0</code> can mean zero devices or an error obtaining the number
*/
public static int getPushInfo(String toUser) {
// If Push API config properties aren't set, no info can be obtained.
if (PUSH_API_KEY.equals(null) || PUSH_API_URL.equals(null)) return 0;
try {
Map<String, String> headers = Map.of("Accept", "application/json");
var httpResponse = HttpUtils.httpRequestRawResponse(
Expand Down

0 comments on commit 38660e6

Please sign in to comment.