mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Split given/family name in updateContact command
This commit is contained in:
parent
27dbc671e0
commit
badbb55ef2
7 changed files with 32 additions and 13 deletions
|
@ -149,7 +149,7 @@ public interface Manager extends Closeable {
|
|||
void deleteContact(RecipientIdentifier.Single recipient);
|
||||
|
||||
void setContactName(
|
||||
RecipientIdentifier.Single recipient, String name
|
||||
RecipientIdentifier.Single recipient, String givenName, final String familyName
|
||||
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
|
||||
|
||||
void setContactsBlocked(
|
||||
|
|
|
@ -705,12 +705,13 @@ class ManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void setContactName(
|
||||
RecipientIdentifier.Single recipient, String name
|
||||
RecipientIdentifier.Single recipient, String givenName, final String familyName
|
||||
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
|
||||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
context.getContactHelper().setContactName(context.getRecipientHelper().resolveRecipient(recipient), name);
|
||||
context.getContactHelper()
|
||||
.setContactName(context.getRecipientHelper().resolveRecipient(recipient), givenName, familyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,10 +17,16 @@ public class ContactHelper {
|
|||
return sourceContact != null && sourceContact.isBlocked();
|
||||
}
|
||||
|
||||
public void setContactName(final RecipientId recipientId, final String name) {
|
||||
public void setContactName(final RecipientId recipientId, final String givenName, final String familyName) {
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||
account.getContactStore().storeContact(recipientId, builder.withGivenName(name).build());
|
||||
if (givenName != null) {
|
||||
builder.withGivenName(givenName);
|
||||
}
|
||||
if (familyName != null) {
|
||||
builder.withFamilyName(familyName);
|
||||
}
|
||||
account.getContactStore().storeContact(recipientId, builder.build());
|
||||
}
|
||||
|
||||
public void setExpirationTimer(RecipientId recipientId, int messageExpirationTimer) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue