Add gift badges device capability

This commit is contained in:
Ehren Kret
2022-04-19 10:09:54 -05:00
parent 796fb3b4cd
commit 9e66f8ac11
11 changed files with 116 additions and 46 deletions

View File

@@ -246,6 +246,7 @@ public class DeviceController {
isDowngrade |= account.isAnnouncementGroupSupported() && !capabilities.isAnnouncementGroup();
isDowngrade |= account.isSenderKeySupported() && !capabilities.isSenderKey();
isDowngrade |= account.isGv1MigrationSupported() && !capabilities.isGv1Migration();
isDowngrade |= account.isGiftBadgesSupported() && !capabilities.isGiftBadges();
if (account.isGroupsV2Supported()) {
try {

View File

@@ -252,6 +252,14 @@ public class Account {
.anyMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories());
}
public boolean isGiftBadgesSupported() {
requireNotStale();
return devices.stream()
.filter(Device::isEnabled)
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isGiftBadges());
}
public boolean isEnabled() {
requireNotStale();

View File

@@ -295,12 +295,15 @@ public class Device {
@JsonProperty
private boolean stories;
@JsonProperty
private boolean giftBadges;
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 stories) {
final boolean pni, final boolean stories, final boolean giftBadges) {
this.gv2 = gv2;
this.gv2_2 = gv2_2;
this.gv2_3 = gv2_3;
@@ -312,6 +315,7 @@ public class Device {
this.changeNumber = changeNumber;
this.pni = pni;
this.stories = stories;
this.giftBadges = giftBadges;
}
public boolean isGv2() {
@@ -357,5 +361,9 @@ public class Device {
public boolean isStories() {
return stories;
}
public boolean isGiftBadges() {
return giftBadges;
}
}
}