mirror of
https://github.com/igniterealtime/Spark.git
synced 2026-08-18 11:10:02 +00:00
SPARK-2119: check if pre-approve is supported
This commit is contained in:
@ -519,7 +519,7 @@ public class RosterDialog implements ActionListener {
|
||||
boolean isNewContact = userEntry == null || userEntry.getGroups().isEmpty();
|
||||
if (isNewContact) {
|
||||
try {
|
||||
roster.preApproveAndCreateEntry(jid, nickname, new String[]{group});
|
||||
addContactToRoster(jid, nickname, new String[]{group}, roster);
|
||||
return true;
|
||||
}
|
||||
catch (XMPPException | SmackException | InterruptedException e) {
|
||||
@ -540,6 +540,17 @@ public class RosterDialog implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void addContactToRoster(BareJid contactJid, String displayName, String[] parentNames, Roster roster) throws SmackException, XMPPException.XMPPErrorException, InterruptedException {
|
||||
if (roster.isSubscriptionPreApprovalSupported()) {
|
||||
try {
|
||||
roster.preApproveAndCreateEntry(contactJid, displayName, parentNames);
|
||||
} catch (SmackException.FeatureNotSupportedException ignored) {
|
||||
}
|
||||
} else {
|
||||
roster.createItemAndRequestSubscription(contactJid, displayName, parentNames);
|
||||
}
|
||||
}
|
||||
|
||||
public List<AccountItem> getAccounts() {
|
||||
List<AccountItem> list = new ArrayList<>();
|
||||
for (Transport transport : TransportUtils.getTransports()) {
|
||||
|
||||
Reference in New Issue
Block a user