Use substring over replaceFirst (#4707) (#4737)

(cherry picked from commit 68457c5e7e)

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
This commit is contained in:
Mattermost Build 2020-08-27 12:43:42 -04:00 committed by GitHub
parent 20d7d87464
commit c3ce1c1f0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -532,7 +532,12 @@ public class CustomPushNotification extends PushNotification {
}
private String removeSenderNameFromMessage(String message, String senderName) {
return message.replaceFirst(senderName, "").replaceFirst(": ", "").trim();
Integer index = message.indexOf(senderName);
if (index == 0) {
message = message.substring(senderName.length());
}
return message.replaceFirst(": ", "").trim();
}
private void notificationReceiptDelivery(String ackId, String postId, String type, boolean isIdLoaded, ResolvePromise promise) {