Include public key with display names

This commit is contained in:
Niels Andriesse 2019-09-12 11:52:03 +10:00
parent dbb07d78b0
commit cbb7f9827c

View File

@ -292,12 +292,16 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
} }
} }
// Loki - Get the sender display name if needed // Loki - Store the sender display name if needed
Optional<String> senderDisplayName = content.senderDisplayName; Optional<String> rawSenderDisplayName = content.senderDisplayName;
if (senderDisplayName.isPresent()) { if (rawSenderDisplayName.isPresent() && rawSenderDisplayName.get().length() > 0) {
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(envelope.getSource(), senderDisplayName.get()); String senderHexEncodedPublicKey = envelope.getSource();
String senderDisplayName = rawSenderDisplayName + " (..." + senderHexEncodedPublicKey.substring(senderHexEncodedPublicKey.length() - 8) + ")";
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(senderHexEncodedPublicKey, senderDisplayName);
} }
// TODO: Deleting the display name
if (content.getDataMessage().isPresent()) { if (content.getDataMessage().isPresent()) {
SignalServiceDataMessage message = content.getDataMessage().get(); SignalServiceDataMessage message = content.getDataMessage().get();
boolean isMediaMessage = message.getAttachments().isPresent() || message.getQuote().isPresent() || message.getSharedContacts().isPresent() || message.getPreviews().isPresent() || message.getSticker().isPresent(); boolean isMediaMessage = message.getAttachments().isPresent() || message.getQuote().isPresent() || message.getSharedContacts().isPresent() || message.getPreviews().isPresent() || message.getSticker().isPresent();