mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-19 23:38:07 +01:00
Add stories capability
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user