mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add mobile-coin-address to updateProfile command
This commit is contained in:
parent
bf75d9b4e0
commit
34c0968f5e
6 changed files with 40 additions and 6 deletions
|
@ -270,7 +270,8 @@ class ManagerImpl implements Manager {
|
|||
updateProfile.getAboutEmoji(),
|
||||
updateProfile.isDeleteAvatar()
|
||||
? Optional.empty()
|
||||
: updateProfile.getAvatar() == null ? null : Optional.of(updateProfile.getAvatar()));
|
||||
: updateProfile.getAvatar() == null ? null : Optional.of(updateProfile.getAvatar()),
|
||||
updateProfile.getMobileCoinAddress());
|
||||
context.getSyncHelper().sendSyncFetchProfileMessage();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ public class UpdateProfile {
|
|||
private final String aboutEmoji;
|
||||
private final File avatar;
|
||||
private final boolean deleteAvatar;
|
||||
private final byte[] mobileCoinAddress;
|
||||
|
||||
private UpdateProfile(final Builder builder) {
|
||||
givenName = builder.givenName;
|
||||
|
@ -18,6 +19,7 @@ public class UpdateProfile {
|
|||
aboutEmoji = builder.aboutEmoji;
|
||||
avatar = builder.avatar;
|
||||
deleteAvatar = builder.deleteAvatar;
|
||||
mobileCoinAddress = builder.mobileCoinAddress;
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
|
@ -32,6 +34,7 @@ public class UpdateProfile {
|
|||
builder.aboutEmoji = copy.getAboutEmoji();
|
||||
builder.avatar = copy.getAvatar();
|
||||
builder.deleteAvatar = copy.isDeleteAvatar();
|
||||
builder.mobileCoinAddress = copy.getMobileCoinAddress();
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
@ -59,6 +62,10 @@ public class UpdateProfile {
|
|||
return deleteAvatar;
|
||||
}
|
||||
|
||||
public byte[] getMobileCoinAddress() {
|
||||
return mobileCoinAddress;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
|
||||
private String givenName;
|
||||
|
@ -67,6 +74,7 @@ public class UpdateProfile {
|
|||
private String aboutEmoji;
|
||||
private File avatar;
|
||||
private boolean deleteAvatar;
|
||||
private byte[] mobileCoinAddress;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
@ -101,6 +109,11 @@ public class UpdateProfile {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder withMobileCoinAddress(final byte[] val) {
|
||||
mobileCoinAddress = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateProfile build() {
|
||||
return new UpdateProfile(this);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public final class ProfileHelper {
|
|||
var profileKey = KeyUtils.createProfileKey();
|
||||
account.setProfileKey(profileKey);
|
||||
context.getAccountHelper().updateAccountAttributes();
|
||||
setProfile(true, true, null, null, null, null, null);
|
||||
setProfile(true, true, null, null, null, null, null, null);
|
||||
// TODO update profile key in storage
|
||||
|
||||
final var recipientIds = account.getRecipientStore().getRecipientIdsWithEnabledProfileSharing();
|
||||
|
@ -144,9 +144,14 @@ public final class ProfileHelper {
|
|||
* @param avatar if avatar is null the image from the local avatar store is used (if present),
|
||||
*/
|
||||
public void setProfile(
|
||||
String givenName, final String familyName, String about, String aboutEmoji, Optional<File> avatar
|
||||
String givenName,
|
||||
final String familyName,
|
||||
String about,
|
||||
String aboutEmoji,
|
||||
Optional<File> avatar,
|
||||
byte[] mobileCoinAddress
|
||||
) throws IOException {
|
||||
setProfile(true, false, givenName, familyName, about, aboutEmoji, avatar);
|
||||
setProfile(true, false, givenName, familyName, about, aboutEmoji, avatar, mobileCoinAddress);
|
||||
}
|
||||
|
||||
public void setProfile(
|
||||
|
@ -156,7 +161,8 @@ public final class ProfileHelper {
|
|||
final String familyName,
|
||||
String about,
|
||||
String aboutEmoji,
|
||||
Optional<File> avatar
|
||||
Optional<File> avatar,
|
||||
byte[] mobileCoinAddress
|
||||
) throws IOException {
|
||||
var profile = getSelfProfile();
|
||||
var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
|
||||
|
@ -172,6 +178,9 @@ public final class ProfileHelper {
|
|||
if (aboutEmoji != null) {
|
||||
builder.withAboutEmoji(aboutEmoji);
|
||||
}
|
||||
if (mobileCoinAddress != null) {
|
||||
builder.withMobileCoinAddress(mobileCoinAddress);
|
||||
}
|
||||
var newProfile = builder.build();
|
||||
|
||||
if (uploadProfile) {
|
||||
|
|
|
@ -234,6 +234,7 @@ public class StorageHelper {
|
|||
accountRecord.getFamilyName().orElse(null),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
|
|
|
@ -493,6 +493,9 @@ Path to the new avatar image file.
|
|||
*--remove-avatar*::
|
||||
Remove the avatar
|
||||
|
||||
*--mobile-coin-address*::
|
||||
New MobileCoin address (Base64 encoded public address)
|
||||
|
||||
=== updateContact
|
||||
|
||||
Update the info associated to a number on our contact list.
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.asamk.signal.output.OutputWriter;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
public class UpdateProfileCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -27,6 +28,7 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
|
|||
subparser.addArgument("--family-name").help("New profile family name (optional)");
|
||||
subparser.addArgument("--about").help("New profile about text");
|
||||
subparser.addArgument("--about-emoji").help("New profile about emoji");
|
||||
subparser.addArgument("--mobile-coin-address").help("New MobileCoin address (Base64 encoded public address)");
|
||||
|
||||
final var avatarOptions = subparser.addMutuallyExclusiveGroup();
|
||||
avatarOptions.addArgument("--avatar").help("Path to new profile avatar");
|
||||
|
@ -41,9 +43,13 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
|
|||
var familyName = ns.getString("family-name");
|
||||
var about = ns.getString("about");
|
||||
var aboutEmoji = ns.getString("about-emoji");
|
||||
var mobileCoinAddressString = ns.getString("mobile-coin-address");
|
||||
var mobileCoinAddress = mobileCoinAddressString == null
|
||||
? null
|
||||
: Base64.getDecoder().decode(mobileCoinAddressString);
|
||||
|
||||
var avatarPath = ns.getString("avatar");
|
||||
boolean removeAvatar = Boolean.TRUE.equals(ns.getBoolean("remove-avatar"));
|
||||
|
||||
File avatarFile = removeAvatar || avatarPath == null ? null : new File(avatarPath);
|
||||
|
||||
try {
|
||||
|
@ -52,6 +58,7 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
|
|||
.withFamilyName(familyName)
|
||||
.withAbout(about)
|
||||
.withAboutEmoji(aboutEmoji)
|
||||
.withMobileCoinAddress(mobileCoinAddress)
|
||||
.withAvatar(avatarFile)
|
||||
.withDeleteAvatar(removeAvatar)
|
||||
.build());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue