Announce support for gift badges if linked device

Fixes #1226
This commit is contained in:
AsamK 2023-04-16 21:17:22 +02:00
parent 842f13b2fc
commit da4cc7dc6b
5 changed files with 31 additions and 21 deletions

View file

@ -41,7 +41,7 @@ import java.nio.channels.OverlappingFileLockException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.function.Consumer; import java.util.function.Consumer;
import static org.asamk.signal.manager.config.ServiceConfig.capabilities; import static org.asamk.signal.manager.config.ServiceConfig.getCapabilities;
class ProvisioningManagerImpl implements ProvisioningManager { class ProvisioningManagerImpl implements ProvisioningManager {
@ -132,7 +132,7 @@ class ProvisioningManagerImpl implements ProvisioningManager {
registrationId, registrationId,
pniRegistrationId, pniRegistrationId,
encryptedDeviceName, encryptedDeviceName,
capabilities)); getCapabilities(false)));
// Create new account with the synced identity // Create new account with the synced identity
var profileKey = ret.getProfileKey() == null ? KeyUtils.createProfileKey() : ret.getProfileKey(); var profileKey = ret.getProfileKey() == null ? KeyUtils.createProfileKey() : ret.getProfileKey();

View file

@ -28,21 +28,7 @@ public class ServiceConfig {
private final static KeyStore iasKeyStore; private final static KeyStore iasKeyStore;
public static final AccountAttributes.Capabilities capabilities;
static { static {
capabilities = new AccountAttributes.Capabilities(false,
true,
false,
true,
true,
true,
true,
true,
false,
false,
false);
try { try {
TrustStore contactTrustStore = new IasTrustStore(); TrustStore contactTrustStore = new IasTrustStore();
@ -56,6 +42,21 @@ public class ServiceConfig {
} }
} }
public static AccountAttributes.Capabilities getCapabilities(boolean isPrimaryDevice) {
final var giftBadges = !isPrimaryDevice;
return new AccountAttributes.Capabilities(false,
true,
false,
true,
true,
true,
true,
true,
giftBadges,
false,
false);
}
public static boolean isSignalClientAvailable() { public static boolean isSignalClientAvailable() {
try { try {
try { try {

View file

@ -18,8 +18,6 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import static org.asamk.signal.manager.config.ServiceConfig.capabilities;
public class IdentityHelper { public class IdentityHelper {
private final static Logger logger = LoggerFactory.getLogger(IdentityHelper.class); private final static Logger logger = LoggerFactory.getLogger(IdentityHelper.class);
@ -75,7 +73,7 @@ public class IdentityHelper {
final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId); final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId); final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
if (capabilities.getUuid()) { if (account.getAccountCapabilities().getUuid()) {
if (serviceId.isUnknown()) { if (serviceId.isUnknown()) {
return null; return null;
} }

View file

@ -817,6 +817,9 @@ public final class IncomingMessageHandler {
} }
} }
} }
if (message.getGiftBadge().isPresent()) {
handleIncomingGiftBadge(message.getGiftBadge().get());
}
if (message.getProfileKey().isPresent()) { if (message.getProfileKey().isPresent()) {
handleIncomingProfileKey(message.getProfileKey().get(), source.recipientId()); handleIncomingProfileKey(message.getProfileKey().get(), source.recipientId());
} }
@ -833,6 +836,10 @@ public final class IncomingMessageHandler {
return actions; return actions;
} }
private void handleIncomingGiftBadge(final SignalServiceDataMessage.GiftBadge giftBadge) {
// TODO
}
private List<HandleAction> handleSignalServiceStoryMessage( private List<HandleAction> handleSignalServiceStoryMessage(
SignalServiceStoryMessage message, RecipientId source, boolean ignoreAttachments SignalServiceStoryMessage message, RecipientId source, boolean ignoreAttachments
) { ) {

View file

@ -98,7 +98,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Supplier; import java.util.function.Supplier;
import static org.asamk.signal.manager.config.ServiceConfig.capabilities; import static org.asamk.signal.manager.config.ServiceConfig.getCapabilities;
public class SignalAccount implements Closeable { public class SignalAccount implements Closeable {
@ -1328,13 +1328,17 @@ public class SignalAccount implements Closeable {
registrationLock != null ? registrationLock : getRegistrationLock(), registrationLock != null ? registrationLock : getRegistrationLock(),
getSelfUnidentifiedAccessKey(), getSelfUnidentifiedAccessKey(),
isUnrestrictedUnidentifiedAccess(), isUnrestrictedUnidentifiedAccess(),
capabilities, getAccountCapabilities(),
isDiscoverableByPhoneNumber(), isDiscoverableByPhoneNumber(),
encryptedDeviceName, encryptedDeviceName,
getLocalPniRegistrationId(), getLocalPniRegistrationId(),
null); // TODO recoveryPassword? null); // TODO recoveryPassword?
} }
public AccountAttributes.Capabilities getAccountCapabilities() {
return getCapabilities(isPrimaryDevice());
}
public ServiceId getAccountId(ServiceIdType serviceIdType) { public ServiceId getAccountId(ServiceIdType serviceIdType) {
return serviceIdType.equals(ServiceIdType.ACI) ? aci : pni; return serviceIdType.equals(ServiceIdType.ACI) ? aci : pni;
} }