Refactor receive api

This commit is contained in:
AsamK 2021-11-03 20:43:39 +01:00
parent b615a4b04d
commit 9075cc1a30
36 changed files with 1510 additions and 970 deletions

View file

@ -1,18 +1,18 @@
package org.asamk.signal.json;
import org.asamk.signal.manager.api.MessageEnvelope;
import org.asamk.signal.util.Util;
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
public record JsonContactName(
String display, String given, String family, String prefix, String suffix, String middle
) {
static JsonContactName from(SharedContact.Name name) {
return new JsonContactName(Util.getStringIfNotBlank(name.getDisplay()),
Util.getStringIfNotBlank(name.getGiven()),
Util.getStringIfNotBlank(name.getFamily()),
Util.getStringIfNotBlank(name.getPrefix()),
Util.getStringIfNotBlank(name.getSuffix()),
Util.getStringIfNotBlank(name.getMiddle()));
static JsonContactName from(MessageEnvelope.Data.SharedContact.Name name) {
return new JsonContactName(Util.getStringIfNotBlank(name.display()),
Util.getStringIfNotBlank(name.given()),
Util.getStringIfNotBlank(name.family()),
Util.getStringIfNotBlank(name.prefix()),
Util.getStringIfNotBlank(name.suffix()),
Util.getStringIfNotBlank(name.middle()));
}
}