1
0
Fork 1

Use known gateways to get list of all gateways

(cherry picked from commit 749790c52698b7f079760d52beed862e979c428f)
This commit is contained in:
Stephen Paul Weber 2024-09-14 23:46:10 -05:00 committed by Arne
parent 2a56dfa683
commit de36c966b1

View file

@ -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<String> 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<String> 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<String> fromPrefs = getPreferences().getStringSet("pstn_gateways", Set.of("UPGRADE"));