Add mobile-coin-address to updateProfile command
This commit is contained in:
		
							parent
							
								
									bf75d9b4e0
								
							
						
					
					
						commit
						34c0968f5e
					
				@ -270,7 +270,8 @@ class ManagerImpl implements Manager {
 | 
				
			|||||||
                        updateProfile.getAboutEmoji(),
 | 
					                        updateProfile.getAboutEmoji(),
 | 
				
			||||||
                        updateProfile.isDeleteAvatar()
 | 
					                        updateProfile.isDeleteAvatar()
 | 
				
			||||||
                                ? Optional.empty()
 | 
					                                ? Optional.empty()
 | 
				
			||||||
                                : updateProfile.getAvatar() == null ? null : Optional.of(updateProfile.getAvatar()));
 | 
					                                : updateProfile.getAvatar() == null ? null : Optional.of(updateProfile.getAvatar()),
 | 
				
			||||||
 | 
					                        updateProfile.getMobileCoinAddress());
 | 
				
			||||||
        context.getSyncHelper().sendSyncFetchProfileMessage();
 | 
					        context.getSyncHelper().sendSyncFetchProfileMessage();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,7 @@ public class UpdateProfile {
 | 
				
			|||||||
    private final String aboutEmoji;
 | 
					    private final String aboutEmoji;
 | 
				
			||||||
    private final File avatar;
 | 
					    private final File avatar;
 | 
				
			||||||
    private final boolean deleteAvatar;
 | 
					    private final boolean deleteAvatar;
 | 
				
			||||||
 | 
					    private final byte[] mobileCoinAddress;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private UpdateProfile(final Builder builder) {
 | 
					    private UpdateProfile(final Builder builder) {
 | 
				
			||||||
        givenName = builder.givenName;
 | 
					        givenName = builder.givenName;
 | 
				
			||||||
@ -18,6 +19,7 @@ public class UpdateProfile {
 | 
				
			|||||||
        aboutEmoji = builder.aboutEmoji;
 | 
					        aboutEmoji = builder.aboutEmoji;
 | 
				
			||||||
        avatar = builder.avatar;
 | 
					        avatar = builder.avatar;
 | 
				
			||||||
        deleteAvatar = builder.deleteAvatar;
 | 
					        deleteAvatar = builder.deleteAvatar;
 | 
				
			||||||
 | 
					        mobileCoinAddress = builder.mobileCoinAddress;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static Builder newBuilder() {
 | 
					    public static Builder newBuilder() {
 | 
				
			||||||
@ -32,6 +34,7 @@ public class UpdateProfile {
 | 
				
			|||||||
        builder.aboutEmoji = copy.getAboutEmoji();
 | 
					        builder.aboutEmoji = copy.getAboutEmoji();
 | 
				
			||||||
        builder.avatar = copy.getAvatar();
 | 
					        builder.avatar = copy.getAvatar();
 | 
				
			||||||
        builder.deleteAvatar = copy.isDeleteAvatar();
 | 
					        builder.deleteAvatar = copy.isDeleteAvatar();
 | 
				
			||||||
 | 
					        builder.mobileCoinAddress = copy.getMobileCoinAddress();
 | 
				
			||||||
        return builder;
 | 
					        return builder;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -59,6 +62,10 @@ public class UpdateProfile {
 | 
				
			|||||||
        return deleteAvatar;
 | 
					        return deleteAvatar;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public byte[] getMobileCoinAddress() {
 | 
				
			||||||
 | 
					        return mobileCoinAddress;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static final class Builder {
 | 
					    public static final class Builder {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private String givenName;
 | 
					        private String givenName;
 | 
				
			||||||
@ -67,6 +74,7 @@ public class UpdateProfile {
 | 
				
			|||||||
        private String aboutEmoji;
 | 
					        private String aboutEmoji;
 | 
				
			||||||
        private File avatar;
 | 
					        private File avatar;
 | 
				
			||||||
        private boolean deleteAvatar;
 | 
					        private boolean deleteAvatar;
 | 
				
			||||||
 | 
					        private byte[] mobileCoinAddress;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private Builder() {
 | 
					        private Builder() {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -101,6 +109,11 @@ public class UpdateProfile {
 | 
				
			|||||||
            return this;
 | 
					            return this;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder withMobileCoinAddress(final byte[] val) {
 | 
				
			||||||
 | 
					            mobileCoinAddress = val;
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public UpdateProfile build() {
 | 
					        public UpdateProfile build() {
 | 
				
			||||||
            return new UpdateProfile(this);
 | 
					            return new UpdateProfile(this);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -64,7 +64,7 @@ public final class ProfileHelper {
 | 
				
			|||||||
        var profileKey = KeyUtils.createProfileKey();
 | 
					        var profileKey = KeyUtils.createProfileKey();
 | 
				
			||||||
        account.setProfileKey(profileKey);
 | 
					        account.setProfileKey(profileKey);
 | 
				
			||||||
        context.getAccountHelper().updateAccountAttributes();
 | 
					        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
 | 
					        // TODO update profile key in storage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final var recipientIds = account.getRecipientStore().getRecipientIdsWithEnabledProfileSharing();
 | 
					        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),
 | 
					     * @param avatar     if avatar is null the image from the local avatar store is used (if present),
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void setProfile(
 | 
					    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 {
 | 
					    ) throws IOException {
 | 
				
			||||||
        setProfile(true, false, givenName, familyName, about, aboutEmoji, avatar);
 | 
					        setProfile(true, false, givenName, familyName, about, aboutEmoji, avatar, mobileCoinAddress);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setProfile(
 | 
					    public void setProfile(
 | 
				
			||||||
@ -156,7 +161,8 @@ public final class ProfileHelper {
 | 
				
			|||||||
            final String familyName,
 | 
					            final String familyName,
 | 
				
			||||||
            String about,
 | 
					            String about,
 | 
				
			||||||
            String aboutEmoji,
 | 
					            String aboutEmoji,
 | 
				
			||||||
            Optional<File> avatar
 | 
					            Optional<File> avatar,
 | 
				
			||||||
 | 
					            byte[] mobileCoinAddress
 | 
				
			||||||
    ) throws IOException {
 | 
					    ) throws IOException {
 | 
				
			||||||
        var profile = getSelfProfile();
 | 
					        var profile = getSelfProfile();
 | 
				
			||||||
        var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
 | 
					        var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
 | 
				
			||||||
@ -172,6 +178,9 @@ public final class ProfileHelper {
 | 
				
			|||||||
        if (aboutEmoji != null) {
 | 
					        if (aboutEmoji != null) {
 | 
				
			||||||
            builder.withAboutEmoji(aboutEmoji);
 | 
					            builder.withAboutEmoji(aboutEmoji);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (mobileCoinAddress != null) {
 | 
				
			||||||
 | 
					            builder.withMobileCoinAddress(mobileCoinAddress);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        var newProfile = builder.build();
 | 
					        var newProfile = builder.build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (uploadProfile) {
 | 
					        if (uploadProfile) {
 | 
				
			||||||
 | 
				
			|||||||
@ -234,6 +234,7 @@ public class StorageHelper {
 | 
				
			|||||||
                        accountRecord.getFamilyName().orElse(null),
 | 
					                        accountRecord.getFamilyName().orElse(null),
 | 
				
			||||||
                        null,
 | 
					                        null,
 | 
				
			||||||
                        null,
 | 
					                        null,
 | 
				
			||||||
 | 
					                        null,
 | 
				
			||||||
                        null);
 | 
					                        null);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -493,6 +493,9 @@ Path to the new avatar image file.
 | 
				
			|||||||
*--remove-avatar*::
 | 
					*--remove-avatar*::
 | 
				
			||||||
Remove the avatar
 | 
					Remove the avatar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*--mobile-coin-address*::
 | 
				
			||||||
 | 
					New MobileCoin address (Base64 encoded public address)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=== updateContact
 | 
					=== updateContact
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Update the info associated to a number on our contact list.
 | 
					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.File;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.util.Base64;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class UpdateProfileCommand implements JsonRpcLocalCommand {
 | 
					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("--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");
 | 
				
			||||||
 | 
					        subparser.addArgument("--mobile-coin-address").help("New MobileCoin address (Base64 encoded public address)");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final var avatarOptions = subparser.addMutuallyExclusiveGroup();
 | 
					        final var avatarOptions = subparser.addMutuallyExclusiveGroup();
 | 
				
			||||||
        avatarOptions.addArgument("--avatar").help("Path to new profile avatar");
 | 
					        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 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 mobileCoinAddressString = ns.getString("mobile-coin-address");
 | 
				
			||||||
 | 
					        var mobileCoinAddress = mobileCoinAddressString == null
 | 
				
			||||||
 | 
					                ? null
 | 
				
			||||||
 | 
					                : Base64.getDecoder().decode(mobileCoinAddressString);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var avatarPath = ns.getString("avatar");
 | 
					        var avatarPath = ns.getString("avatar");
 | 
				
			||||||
        boolean removeAvatar = Boolean.TRUE.equals(ns.getBoolean("remove-avatar"));
 | 
					        boolean removeAvatar = Boolean.TRUE.equals(ns.getBoolean("remove-avatar"));
 | 
				
			||||||
 | 
					 | 
				
			||||||
        File avatarFile = removeAvatar || avatarPath == null ? null : new File(avatarPath);
 | 
					        File avatarFile = removeAvatar || avatarPath == null ? null : new File(avatarPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@ -52,6 +58,7 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
 | 
				
			|||||||
                    .withFamilyName(familyName)
 | 
					                    .withFamilyName(familyName)
 | 
				
			||||||
                    .withAbout(about)
 | 
					                    .withAbout(about)
 | 
				
			||||||
                    .withAboutEmoji(aboutEmoji)
 | 
					                    .withAboutEmoji(aboutEmoji)
 | 
				
			||||||
 | 
					                    .withMobileCoinAddress(mobileCoinAddress)
 | 
				
			||||||
                    .withAvatar(avatarFile)
 | 
					                    .withAvatar(avatarFile)
 | 
				
			||||||
                    .withDeleteAvatar(removeAvatar)
 | 
					                    .withDeleteAvatar(removeAvatar)
 | 
				
			||||||
                    .build());
 | 
					                    .build());
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user