[FIX] Wrong username on push notifications (#2825)

This commit is contained in:
Diego Mello 2021-01-22 17:20:04 -03:00 committed by GitHub
parent b10c5db5b5
commit cf59644a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 10 deletions

View File

@ -257,7 +257,6 @@ public class CustomPushNotification extends PushNotification {
Notification.MessagingStyle messageStyle; Notification.MessagingStyle messageStyle;
Gson gson = new Gson(); Gson gson = new Gson();
Ejson ejson = gson.fromJson(bundle.getString("ejson", "{}"), Ejson.class);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
messageStyle = new Notification.MessagingStyle(""); messageStyle = new Notification.MessagingStyle("");
@ -278,25 +277,19 @@ public class CustomPushNotification extends PushNotification {
long timestamp = data.getLong("time"); long timestamp = data.getLong("time");
String message = data.getString("message"); String message = data.getString("message");
String username = data.getString("username");
String senderId = data.getString("senderId"); String senderId = data.getString("senderId");
String avatarUri = data.getString("avatarUri"); String avatarUri = data.getString("avatarUri");
Ejson ejson = gson.fromJson(data.getString("ejson", "{}"), Ejson.class);
String m = extractMessage(message, ejson); String m = extractMessage(message, ejson);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
messageStyle.addMessage(m, timestamp, username); messageStyle.addMessage(m, timestamp, ejson.senderName);
} else { } else {
Bitmap avatar = getAvatar(avatarUri); Bitmap avatar = getAvatar(avatarUri);
String name = username;
if (ejson.senderName != null) {
name = ejson.senderName;
}
Person.Builder sender = new Person.Builder() Person.Builder sender = new Person.Builder()
.setKey(senderId) .setKey(senderId)
.setName(name); .setName(ejson.senderName);
if (avatar != null) { if (avatar != null) {
sender.setIcon(Icon.createWithBitmap(avatar)); sender.setIcon(Icon.createWithBitmap(avatar));