From 0c46aaac41dddbd484d8398ac1cdac2da0dc2930 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sat, 14 Sep 2024 23:46:10 -0500 Subject: [PATCH] Use known gateways to get list of all gateways (cherry picked from commit 749790c52698b7f079760d52beed862e979c428f) --- .../conversations/ui/ConversationsActivity.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java index 8b5cc5a16a..7574974468 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java @@ -95,6 +95,7 @@ import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; @@ -710,14 +711,9 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONNECTION_SERVICE)) return false; } - Set pstnGateways = new HashSet<>(); - for (Account account : xmppConnectionService.getAccounts()) { - for (Contact contact : account.getRoster().getContacts()) { - if (contact.getPresences().anyIdentity("gateway", "pstn")) { - pstnGateways.add(contact.getJid().asBareJid().toEscapedString()); - } - } - } + Set pstnGateways = xmppConnectionService.getAccounts().stream() + .flatMap(a -> a.getGateways("pstn").stream()) + .map(a -> a.getJid().asBareJid().toString()).collect(Collectors.toSet()); if (pstnGateways.size() < 1) return false; Set fromPrefs = getPreferences().getStringSet("pstn_gateways", Set.of("UPGRADE"));