mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Extend updateProfile command to set family name
This commit is contained in:
parent
3d361d54bb
commit
b7f05a1c80
5 changed files with 34 additions and 18 deletions
|
@ -354,18 +354,22 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name if null, the previous name will be kept
|
* @param givenName if null, the previous givenName will be kept
|
||||||
|
* @param familyName if null, the previous familyName will be kept
|
||||||
* @param about if null, the previous about text will be kept
|
* @param about if null, the previous about text will be kept
|
||||||
* @param aboutEmoji if null, the previous about emoji will be kept
|
* @param aboutEmoji if null, the previous about emoji will be kept
|
||||||
* @param avatar if avatar is null the image from the local avatar store is used (if present),
|
* @param avatar if avatar is null the image from the local avatar store is used (if present),
|
||||||
* if it's Optional.absent(), the avatar will be removed
|
|
||||||
*/
|
*/
|
||||||
public void setProfile(String name, String about, String aboutEmoji, Optional<File> avatar) throws IOException {
|
public void setProfile(
|
||||||
|
String givenName, final String familyName, String about, String aboutEmoji, Optional<File> avatar
|
||||||
|
) throws IOException {
|
||||||
var profile = getRecipientProfile(account.getSelfRecipientId());
|
var profile = getRecipientProfile(account.getSelfRecipientId());
|
||||||
var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
|
var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
|
||||||
if (name != null) {
|
if (givenName != null) {
|
||||||
builder.withGivenName(name);
|
builder.withGivenName(givenName);
|
||||||
builder.withFamilyName(null);
|
}
|
||||||
|
if (familyName != null) {
|
||||||
|
builder.withFamilyName(familyName);
|
||||||
}
|
}
|
||||||
if (about != null) {
|
if (about != null) {
|
||||||
builder.withAbout(about);
|
builder.withAbout(about);
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class RegistrationManager implements Closeable {
|
||||||
|
|
||||||
m.refreshPreKeys();
|
m.refreshPreKeys();
|
||||||
// Set an initial empty profile so user can be added to groups
|
// Set an initial empty profile so user can be added to groups
|
||||||
m.setProfile(null, null, null, null);
|
m.setProfile(null, null, null, null, null);
|
||||||
|
|
||||||
final var result = m;
|
final var result = m;
|
||||||
m = null;
|
m = null;
|
||||||
|
|
|
@ -289,18 +289,28 @@ Specify the safety number of the key, only use this option if you have verified
|
||||||
|
|
||||||
=== updateProfile
|
=== updateProfile
|
||||||
|
|
||||||
Update the name and avatar image visible by message recipients for the current users.
|
Update the profile information shown to message recipients.
|
||||||
The profile is stored encrypted on the Signal servers.
|
The profile is stored encrypted on the Signal servers.
|
||||||
The decryption key is sent with every outgoing messages to contacts.
|
The decryption key is sent with every outgoing messages to contacts and included
|
||||||
|
in every group.
|
||||||
|
|
||||||
*--name*::
|
*--given-name* NAME, *--name* NAME::
|
||||||
New name visible by message recipients.
|
New (given) name.
|
||||||
|
|
||||||
*--avatar*::
|
*--family-name* FAMILY_NAME::
|
||||||
Path to the new avatar visible by message recipients.
|
New family name.
|
||||||
|
|
||||||
|
*--about* ABOUT_TEXT::
|
||||||
|
New profile status text.
|
||||||
|
|
||||||
|
*--about-emoji* EMOJI::
|
||||||
|
New profile status emoji.
|
||||||
|
|
||||||
|
*--avatar* AVATAR_FILE::
|
||||||
|
Path to the new avatar image file.
|
||||||
|
|
||||||
*--remove-avatar*::
|
*--remove-avatar*::
|
||||||
Remove the avatar visible by message recipients.
|
Remove the avatar
|
||||||
|
|
||||||
=== updateContact
|
=== updateContact
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ public class UpdateProfileCommand implements LocalCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.addArgument("--name").help("New profile name");
|
subparser.addArgument("--given-name", "--name").help("New profile (given) name");
|
||||||
|
subparser.addArgument("--family-name").help("New profile family name (optional)");
|
||||||
subparser.addArgument("--about").help("New profile about text");
|
subparser.addArgument("--about").help("New profile about text");
|
||||||
subparser.addArgument("--about-emoji").help("New profile about emoji");
|
subparser.addArgument("--about-emoji").help("New profile about emoji");
|
||||||
|
|
||||||
|
@ -29,7 +30,8 @@ public class UpdateProfileCommand implements LocalCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||||
var name = ns.getString("name");
|
var givenName = ns.getString("given_name");
|
||||||
|
var familyName = ns.getString("family_name");
|
||||||
var about = ns.getString("about");
|
var about = ns.getString("about");
|
||||||
var aboutEmoji = ns.getString("about_emoji");
|
var aboutEmoji = ns.getString("about_emoji");
|
||||||
var avatarPath = ns.getString("avatar");
|
var avatarPath = ns.getString("avatar");
|
||||||
|
@ -40,7 +42,7 @@ public class UpdateProfileCommand implements LocalCommand {
|
||||||
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m.setProfile(name, about, aboutEmoji, avatarFile);
|
m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IOErrorException("Update profile error: " + e.getMessage());
|
throw new IOErrorException("Update profile error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -372,7 +372,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
Optional<File> avatarFile = removeAvatar
|
Optional<File> avatarFile = removeAvatar
|
||||||
? Optional.absent()
|
? Optional.absent()
|
||||||
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
||||||
m.setProfile(name, about, aboutEmoji, avatarFile);
|
m.setProfile(name, null, about, aboutEmoji, avatarFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue