From 39cdbb757dc9f2c21f25e00c800674e8cfe739f3 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Mon, 2 Dec 2019 12:25:33 -0300 Subject: [PATCH] MM-20779 Handle Android notification reply with special characters (#3636) --- .../NotificationReplyBroadcastReceiver.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java b/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java index 70f89ce69..df6e045db 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java @@ -21,6 +21,9 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; +import org.json.JSONObject; +import org.json.JSONException; + import com.mattermost.react_native_interface.ResolvePromise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.WritableMap; @@ -114,11 +117,15 @@ public class NotificationReplyBroadcastReceiver extends BroadcastReceiver { } protected String buildReplyPost(String channelId, String rootId, String message) { - return "{" - + "\"channel_id\": \"" + channelId + "\"," - + "\"message\": \"" + message + "\"," - + "\"root_id\": \"" + rootId + "\"" - + "}"; + try { + JSONObject json = new JSONObject(); + json.put("channel_id", channelId); + json.put("message", message); + json.put("root_id", rootId); + return json.toString(); + } catch(JSONException e) { + return "{}"; + } } protected void onReplyFailed(NotificationManager notificationManager, int notificationId, String channelId) {