Add stories capability

This commit is contained in:
Chris Eager
2022-03-02 15:16:21 -08:00
committed by GitHub
parent faa6ae284a
commit 9fc5002619
12 changed files with 144 additions and 43 deletions

View File

@@ -239,6 +239,8 @@ public class DeviceController {
private boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities, String userAgent) {
boolean isDowngrade = false;
// TODO stories capability
// isDowngrade |= account.isStoriesSupported() && !capabilities.isStories();
isDowngrade |= account.isPniSupported() && !capabilities.isPni();
isDowngrade |= account.isChangeNumberSupported() && !capabilities.isChangeNumber();
isDowngrade |= account.isAnnouncementGroupSupported() && !capabilities.isAnnouncementGroup();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 Signal Messenger, LLC
* Copyright 2013-2022 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
@@ -16,7 +16,8 @@ public class UserCapabilities {
account.isGv1MigrationSupported(),
account.isSenderKeySupported(),
account.isAnnouncementGroupSupported(),
account.isChangeNumberSupported());
account.isChangeNumberSupported(),
account.isStoriesSupported());
}
@JsonProperty
@@ -34,19 +35,25 @@ public class UserCapabilities {
@JsonProperty
private boolean changeNumber;
public UserCapabilities() {}
@JsonProperty
private boolean stories;
public UserCapabilities() {
}
public UserCapabilities(final boolean gv2,
boolean gv1Migration,
final boolean senderKey,
final boolean announcementGroup,
final boolean changeNumber) {
final boolean changeNumber,
final boolean stories) {
this.gv2 = gv2;
this.gv2 = gv2;
this.gv1Migration = gv1Migration;
this.senderKey = senderKey;
this.announcementGroup = announcementGroup;
this.changeNumber = changeNumber;
this.stories = stories;
}
public boolean isGv2() {
@@ -68,4 +75,8 @@ public class UserCapabilities {
public boolean isChangeNumber() {
return changeNumber;
}
public boolean isStories() {
return stories;
}
}

View File

@@ -242,6 +242,16 @@ public class Account {
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isPni());
}
public boolean isStoriesSupported() {
requireNotStale();
return devices.stream()
.filter(Device::isEnabled)
// TODO stories capability
// .allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories());
.anyMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories());
}
public boolean isEnabled() {
requireNotStale();

View File

@@ -188,7 +188,7 @@ public class Device {
return (id == MASTER_ID && hasChannel && signedPreKey != null) ||
(id != MASTER_ID && hasChannel && signedPreKey != null && lastSeen > (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30)));
}
public boolean getFetchesMessages() {
return fetchesMessages;
}
@@ -295,12 +295,15 @@ public class Device {
@JsonProperty
private boolean pni;
@JsonProperty
private boolean stories;
public DeviceCapabilities() {
}
public DeviceCapabilities(boolean gv2, final boolean gv2_2, final boolean gv2_3, boolean storage, boolean transfer,
boolean gv1Migration, final boolean senderKey, final boolean announcementGroup, final boolean changeNumber,
final boolean pni) {
final boolean pni, final boolean stories) {
this.gv2 = gv2;
this.gv2_2 = gv2_2;
this.gv2_3 = gv2_3;
@@ -311,6 +314,7 @@ public class Device {
this.announcementGroup = announcementGroup;
this.changeNumber = changeNumber;
this.pni = pni;
this.stories = stories;
}
public boolean isGv2() {
@@ -352,5 +356,9 @@ public class Device {
public boolean isPni() {
return pni;
}
public boolean isStories() {
return stories;
}
}
}