mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Allow using data URIs for updateGroup/updateProfile avatars
Fixes #1082
This commit is contained in:
parent
dcaf1cc189
commit
5771bb858f
11 changed files with 60 additions and 73 deletions
|
@ -147,7 +147,7 @@ public class DbusManagerImpl implements Manager {
|
|||
emptyIfNull(updateProfile.getFamilyName()),
|
||||
emptyIfNull(updateProfile.getAbout()),
|
||||
emptyIfNull(updateProfile.getAboutEmoji()),
|
||||
updateProfile.getAvatar() == null ? "" : updateProfile.getAvatar().getPath(),
|
||||
updateProfile.getAvatar() == null ? "" : updateProfile.getAvatar(),
|
||||
updateProfile.isDeleteAvatar());
|
||||
}
|
||||
|
||||
|
@ -231,11 +231,11 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
||||
final String name, final Set<RecipientIdentifier.Single> members, final File avatarFile
|
||||
final String name, final Set<RecipientIdentifier.Single> members, final String avatarFile
|
||||
) throws IOException, AttachmentInvalidException {
|
||||
final var newGroupId = signal.createGroup(emptyIfNull(name),
|
||||
members.stream().map(RecipientIdentifier.Single::getIdentifier).toList(),
|
||||
avatarFile == null ? "" : avatarFile.getPath());
|
||||
avatarFile == null ? "" : avatarFile);
|
||||
return new Pair<>(GroupId.unknownVersion(newGroupId), new SendGroupMessageResults(0, List.of()));
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ public class DbusManagerImpl implements Manager {
|
|||
if (updateGroup.getAvatarFile() != null) {
|
||||
group.Set("org.asamk.Signal.Group",
|
||||
"Avatar",
|
||||
updateGroup.getAvatarFile() == null ? "" : updateGroup.getAvatarFile().getPath());
|
||||
updateGroup.getAvatarFile() == null ? "" : updateGroup.getAvatarFile());
|
||||
}
|
||||
if (updateGroup.getExpirationTimer() != null) {
|
||||
group.Set("org.asamk.Signal.Group", "MessageExpirationTimer", updateGroup.getExpirationTimer());
|
||||
|
|
|
@ -618,7 +618,7 @@ public class DbusSignalImpl implements Signal {
|
|||
avatar = nullIfEmpty(avatar);
|
||||
final var memberIdentifiers = getSingleRecipientIdentifiers(members, m.getSelfNumber());
|
||||
if (groupId == null) {
|
||||
final var results = m.createGroup(name, memberIdentifiers, avatar == null ? null : new File(avatar));
|
||||
final var results = m.createGroup(name, memberIdentifiers, avatar);
|
||||
updateGroups();
|
||||
checkGroupSendMessageResults(results.second().timestamp(), results.second().results());
|
||||
return results.first().serialize();
|
||||
|
@ -627,7 +627,7 @@ public class DbusSignalImpl implements Signal {
|
|||
UpdateGroup.newBuilder()
|
||||
.withName(name)
|
||||
.withMembers(memberIdentifiers)
|
||||
.withAvatarFile(avatar == null ? null : new File(avatar))
|
||||
.withAvatarFile(avatar)
|
||||
.build());
|
||||
if (results != null) {
|
||||
checkGroupSendMessageResults(results.timestamp(), results.results());
|
||||
|
@ -687,7 +687,7 @@ public class DbusSignalImpl implements Signal {
|
|||
about = nullIfEmpty(about);
|
||||
aboutEmoji = nullIfEmpty(aboutEmoji);
|
||||
avatarPath = nullIfEmpty(avatarPath);
|
||||
File avatarFile = removeAvatar || avatarPath == null ? null : new File(avatarPath);
|
||||
final var avatarFile = removeAvatar || avatarPath == null ? null : avatarPath;
|
||||
m.updateProfile(UpdateProfile.newBuilder()
|
||||
.withGivenName(givenName)
|
||||
.withFamilyName(familyName)
|
||||
|
@ -1270,7 +1270,7 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
private void setGroupAvatar(final String avatar) {
|
||||
updateGroup(UpdateGroup.newBuilder().withAvatarFile(new File(avatar)).build());
|
||||
updateGroup(UpdateGroup.newBuilder().withAvatarFile(avatar).build());
|
||||
}
|
||||
|
||||
private void setMessageExpirationTime(final int expirationTime) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue