mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-29 21:22:15 +01:00
Fix contact sync by not requiring upload specs for avatars.
This commit is contained in:
committed by
mtang-signal
parent
46bc2589b5
commit
4447433ffe
@@ -1,36 +1,33 @@
|
||||
/**
|
||||
* Copyright (C) 2014-2016 Open Whisper Systems
|
||||
*
|
||||
* <p>
|
||||
* Licensed according to the LICENSE file in this repository.
|
||||
*/
|
||||
|
||||
package org.whispersystems.signalservice.api.messages.multidevice;
|
||||
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class DeviceContact {
|
||||
|
||||
private final Optional<ACI> aci;
|
||||
private final Optional<String> e164;
|
||||
private final Optional<String> name;
|
||||
private final Optional<SignalServiceAttachmentStream> avatar;
|
||||
private final Optional<String> color;
|
||||
private final Optional<VerifiedMessage> verified;
|
||||
private final Optional<ProfileKey> profileKey;
|
||||
private final Optional<Integer> expirationTimer;
|
||||
private final Optional<Integer> inboxPosition;
|
||||
private final boolean archived;
|
||||
private final Optional<ACI> aci;
|
||||
private final Optional<String> e164;
|
||||
private final Optional<String> name;
|
||||
private final Optional<DeviceContactAvatar> avatar;
|
||||
private final Optional<String> color;
|
||||
private final Optional<VerifiedMessage> verified;
|
||||
private final Optional<ProfileKey> profileKey;
|
||||
private final Optional<Integer> expirationTimer;
|
||||
private final Optional<Integer> inboxPosition;
|
||||
private final boolean archived;
|
||||
|
||||
public DeviceContact(Optional<ACI> aci,
|
||||
Optional<String> e164,
|
||||
Optional<String> name,
|
||||
Optional<SignalServiceAttachmentStream> avatar,
|
||||
Optional<DeviceContactAvatar> avatar,
|
||||
Optional<String> color,
|
||||
Optional<VerifiedMessage> verified,
|
||||
Optional<ProfileKey> profileKey,
|
||||
@@ -54,7 +51,7 @@ public class DeviceContact {
|
||||
this.archived = archived;
|
||||
}
|
||||
|
||||
public Optional<SignalServiceAttachmentStream> getAvatar() {
|
||||
public Optional<DeviceContactAvatar> getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.signalservice.api.messages.multidevice
|
||||
|
||||
import java.io.InputStream
|
||||
|
||||
/**
|
||||
* Data needed to sync a device contact avatar to/from other devices.
|
||||
*/
|
||||
data class DeviceContactAvatar(val inputStream: InputStream, val length: Long, val contentType: String)
|
||||
@@ -47,27 +47,23 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
|
||||
throw new IOException("Missing contact address!");
|
||||
}
|
||||
|
||||
Optional<ACI> aci = Optional.ofNullable(ACI.parseOrNull(details.aci));
|
||||
Optional<String> e164 = Optional.ofNullable(details.number);
|
||||
Optional<String> name = Optional.ofNullable(details.name);
|
||||
Optional<SignalServiceAttachmentStream> avatar = Optional.empty();
|
||||
Optional<String> color = details.color != null ? Optional.of(details.color) : Optional.empty();
|
||||
Optional<VerifiedMessage> verified = Optional.empty();
|
||||
Optional<ProfileKey> profileKey = Optional.empty();
|
||||
Optional<Integer> expireTimer = Optional.empty();
|
||||
Optional<Integer> inboxPosition = Optional.empty();
|
||||
boolean archived = false;
|
||||
Optional<ACI> aci = Optional.ofNullable(ACI.parseOrNull(details.aci));
|
||||
Optional<String> e164 = Optional.ofNullable(details.number);
|
||||
Optional<String> name = Optional.ofNullable(details.name);
|
||||
Optional<DeviceContactAvatar> avatar = Optional.empty();
|
||||
Optional<String> color = details.color != null ? Optional.of(details.color) : Optional.empty();
|
||||
Optional<VerifiedMessage> verified = Optional.empty();
|
||||
Optional<ProfileKey> profileKey = Optional.empty();
|
||||
Optional<Integer> expireTimer = Optional.empty();
|
||||
Optional<Integer> inboxPosition = Optional.empty();
|
||||
boolean archived = false;
|
||||
|
||||
if (details.avatar != null) {
|
||||
if (details.avatar != null && details.avatar.length != null) {
|
||||
long avatarLength = details.avatar.length;
|
||||
InputStream avatarStream = new LimitedInputStream(in, avatarLength);
|
||||
String avatarContentType = details.avatar.contentType;
|
||||
String avatarContentType = details.avatar.contentType != null ? details.avatar.contentType : "image/*";
|
||||
|
||||
avatar = Optional.of(SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(avatarStream)
|
||||
.withContentType(avatarContentType)
|
||||
.withLength(avatarLength)
|
||||
.build());
|
||||
avatar = Optional.of(new DeviceContactAvatar(avatarStream, avatarLength, avatarContentType));
|
||||
}
|
||||
|
||||
if (details.verified != null) {
|
||||
|
||||
Reference in New Issue
Block a user