mirror of
https://github.com/aljazceru/signal-cli.git
synced 2026-01-31 03:24:21 +01:00
Extend updateContact command with nick given/family name and note
This commit is contained in:
@@ -237,9 +237,12 @@ public interface Manager extends Closeable {
|
||||
void deleteContact(RecipientIdentifier.Single recipient);
|
||||
|
||||
void setContactName(
|
||||
RecipientIdentifier.Single recipient,
|
||||
String givenName,
|
||||
final String familyName
|
||||
final RecipientIdentifier.Single recipient,
|
||||
final String givenName,
|
||||
final String familyName,
|
||||
final String nickGivenName,
|
||||
final String nickFamilyName,
|
||||
final String note
|
||||
) throws NotPrimaryDeviceException, UnregisteredRecipientException;
|
||||
|
||||
void setContactsBlocked(
|
||||
|
||||
@@ -17,7 +17,14 @@ public class ContactHelper {
|
||||
return sourceContact != null && sourceContact.isBlocked();
|
||||
}
|
||||
|
||||
public void setContactName(final RecipientId recipientId, final String givenName, final String familyName) {
|
||||
public void setContactName(
|
||||
final RecipientId recipientId,
|
||||
final String givenName,
|
||||
final String familyName,
|
||||
final String nickGivenName,
|
||||
final String nickFamilyName,
|
||||
final String note
|
||||
) {
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||
builder.withIsHidden(false);
|
||||
@@ -27,6 +34,15 @@ public class ContactHelper {
|
||||
if (familyName != null) {
|
||||
builder.withFamilyName(familyName);
|
||||
}
|
||||
if (nickGivenName != null) {
|
||||
builder.withNickNameGivenName(nickGivenName);
|
||||
}
|
||||
if (nickFamilyName != null) {
|
||||
builder.withNickNameFamilyName(nickFamilyName);
|
||||
}
|
||||
if (note != null) {
|
||||
builder.withNote(note);
|
||||
}
|
||||
account.getContactStore().storeContact(recipientId, builder.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -1049,15 +1049,23 @@ public class ManagerImpl implements Manager {
|
||||
|
||||
@Override
|
||||
public void setContactName(
|
||||
RecipientIdentifier.Single recipient,
|
||||
String givenName,
|
||||
final String familyName
|
||||
final RecipientIdentifier.Single recipient,
|
||||
final String givenName,
|
||||
final String familyName,
|
||||
final String nickGivenName,
|
||||
final String nickFamilyName,
|
||||
final String note
|
||||
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
|
||||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
context.getContactHelper()
|
||||
.setContactName(context.getRecipientHelper().resolveRecipient(recipient), givenName, familyName);
|
||||
.setContactName(context.getRecipientHelper().resolveRecipient(recipient),
|
||||
givenName,
|
||||
familyName,
|
||||
nickGivenName,
|
||||
nickFamilyName,
|
||||
note);
|
||||
syncRemoteStorage();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user