Compare commits

...

3 Commits

Author SHA1 Message Date
AsamK
5fafa24974 Create correct nickname record if nickname is empty 2025-12-08 19:09:57 +01:00
AsamK
b26c521930 Extend username documentation
Fixes #1886
2025-12-08 17:44:06 +01:00
AsamK
eb52380ecf Remove now unnecessary check for primary device from updateContact
Fixes #1880
2025-12-08 17:08:38 +01:00
8 changed files with 20 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -271,7 +271,7 @@ public interface Manager extends Closeable {
final String nickGivenName,
final String nickFamilyName,
final String note
) throws NotPrimaryDeviceException, UnregisteredRecipientException;
) throws UnregisteredRecipientException;
void setContactsBlocked(
Collection<RecipientIdentifier.Single> recipient,

View File

@ -1138,10 +1138,7 @@ public class ManagerImpl implements Manager {
final String nickGivenName,
final String nickFamilyName,
final String note
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}
) throws UnregisteredRecipientException {
context.getContactHelper()
.setContactName(context.getRecipientHelper().resolveRecipient(recipient),
givenName,

View File

@ -1,5 +1,6 @@
package org.asamk.signal.manager.syncStorage;
import org.asamk.signal.manager.api.Contact;
import org.asamk.signal.manager.api.PhoneNumberSharingMode;
import org.asamk.signal.manager.api.TrustLevel;
import org.asamk.signal.manager.storage.configuration.ConfigurationStore;
@ -104,10 +105,7 @@ public final class StorageSyncModels {
builder.systemGivenName(emptyIfNull(recipient.getContact().givenName()))
.systemFamilyName(emptyIfNull(recipient.getContact().familyName()))
.systemNickname(emptyIfNull(recipient.getContact().nickName()))
.nickname(new ContactRecord.Name.Builder().given(emptyIfNull(recipient.getContact()
.nickNameGivenName()))
.family(emptyIfNull(recipient.getContact().nickNameFamilyName()))
.build())
.nickname(getNicknameRemoteRecord(recipient.getContact()))
.note(emptyIfNull(recipient.getContact().note()))
.blocked(recipient.getContact().isBlocked())
.whitelisted(recipient.getContact().isProfileSharingEnabled())
@ -126,6 +124,15 @@ public final class StorageSyncModels {
return builder.build();
}
private static ContactRecord.Name getNicknameRemoteRecord(final Contact contact) {
final var given = emptyIfNull(contact.nickNameGivenName());
final var family = emptyIfNull(contact.nickNameFamilyName());
if (given.isEmpty() && family.isEmpty()) {
return null;
}
return new ContactRecord.Name.Builder().given(given).family(family).build();
}
public static GroupV1Record localToRemoteRecord(GroupInfoV1 group) {
final var builder = SignalGroupV1Record.Companion.newBuilder(group.getStorageRecord());
builder.id(ByteString.of(group.getGroupId().serialize()));

View File

@ -285,7 +285,7 @@ In json mode this is outputted as a list of objects.
One or more numbers to check.
[--username [USERNAME ...]]::
One or more usernames to check.
One or more usernames or username links to check.
=== send
@ -759,6 +759,7 @@ If the contact doesn't exist yet, it will be added.
RECIPIENT::
Specify the recipient.
Use "u:" prefix to specify a username or username link.
*--given-name* GIVEN_NAME, *--name* NAME::
New system given name.
@ -999,6 +1000,9 @@ signal-cli -a ACCOUNT verify CODE
Send a message to one or more recipients::
signal-cli -a ACCOUNT send -m "This is a message" [RECIPIENT [RECIPIENT ...]] [-a [ATTACHMENT [ATTACHMENT ...]]]
Send a message to a username (or username link)::
signal-cli -a ACCOUNT send u:someusername.000 -m "This is a message"
Pipe the message content from another process::
uname -a | signal-cli -a ACCOUNT send --message-from-stdin [RECIPIENT [RECIPIENT ...]]

View File

@ -7,7 +7,6 @@ import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.manager.api.UnregisteredRecipientException;
import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.util.CommandUtil;
@ -63,8 +62,6 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
m.setContactName(recipient, givenName, familyName, nickGivenName, nickFamilyName, note);
} catch (IOException e) {
throw new IOErrorException("Update contact error: " + e.getMessage(), e);
} catch (NotPrimaryDeviceException e) {
throw new UserErrorException("This command doesn't work on linked devices.");
} catch (UnregisteredRecipientException e) {
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
}

View File

@ -563,7 +563,7 @@ public class DbusManagerImpl implements Manager {
final String nickGivenName,
final String nickFamilyName,
final String note
) throws NotPrimaryDeviceException {
) {
signal.setContactName(recipient.getIdentifier(), givenName);
}

View File

@ -537,8 +537,6 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
public void setContactName(final String number, final String name) {
try {
m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name, "", null, null, null);
} catch (NotPrimaryDeviceException e) {
throw new Error.Failure("This command doesn't work on linked devices.");
} catch (UnregisteredRecipientException e) {
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
}