Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/iNPUTmice/Conversations.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2021-08-24 15:42:50 +0300
committerDaniel Gultsch <daniel@gultsch.de>2021-08-24 15:42:50 +0300
commit6c88a4b4fa8c2286f19ba4a435cfed58bd66f5eb (patch)
tree1e030cf70008c22842801423f2cd9706bb48e0dd
parent88d7ddf1248909f2b2dc940fee7f48342d650ae6 (diff)
reset affiliation when inviting someone not currently in group. fixes #4146
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 759a0d727..be6c6ce01 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -471,7 +471,6 @@ public class XmppConnectionService extends Service {
private OpenPgpServiceConnection pgpServiceConnection;
private PgpEngine mPgpEngine = null;
private WakeLock wakeLock;
- private PowerManager pm;
private LruCache<String, Bitmap> mBitmapCache;
private final BroadcastReceiver mInternalEventReceiver = new InternalEventReceiver();
private final BroadcastReceiver mInternalScreenEventReceiver = new InternalEventReceiver();
@@ -1172,7 +1171,7 @@ public class XmppConnectionService extends Service {
this.pgpServiceConnection.bindToService();
}
- this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ final PowerManager pm = ContextCompat.getSystemService(this, PowerManager.class);
this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Conversations:Service");
toggleForegroundService();
@@ -3337,35 +3336,26 @@ public class XmppConnectionService extends Service {
public void changeAffiliationInConference(final Conversation conference, Jid user, final MucOptions.Affiliation affiliation, final OnAffiliationChanged callback) {
final Jid jid = user.asBareJid();
- IqPacket request = this.mIqGenerator.changeAffiliation(conference, jid, affiliation.toString());
- sendIqPacket(conference.getAccount(), request, new OnIqPacketReceived() {
- @Override
- public void onIqPacketReceived(Account account, IqPacket packet) {
- if (packet.getType() == IqPacket.TYPE.RESULT) {
- conference.getMucOptions().changeAffiliation(jid, affiliation);
- getAvatarService().clear(conference);
+ final IqPacket request = this.mIqGenerator.changeAffiliation(conference, jid, affiliation.toString());
+ sendIqPacket(conference.getAccount(), request, (account, response) -> {
+ if (response.getType() == IqPacket.TYPE.RESULT) {
+ conference.getMucOptions().changeAffiliation(jid, affiliation);
+ getAvatarService().clear(conference);
+ if (callback != null) {
callback.onAffiliationChangedSuccessful(jid);
} else {
- callback.onAffiliationChangeFailed(jid, R.string.could_not_change_affiliation);
+ Log.d(Config.LOGTAG, "changed affiliation of " + user + " to " + affiliation);
}
+ } else if (callback != null) {
+ callback.onAffiliationChangeFailed(jid, R.string.could_not_change_affiliation);
+ } else {
+ Log.d(Config.LOGTAG, "unable to change affiliation");
}
});
}
- public void changeAffiliationsInConference(final Conversation conference, MucOptions.Affiliation before, MucOptions.Affiliation after) {
- List<Jid> jids = new ArrayList<>();
- for (MucOptions.User user : conference.getMucOptions().getUsers()) {
- if (user.getAffiliation() == before && user.getRealJid() != null) {
- jids.add(user.getRealJid());
- }
- }
- IqPacket request = this.mIqGenerator.changeAffiliation(conference, jids, after.toString());
- sendIqPacket(conference.getAccount(), request, mDefaultIqHandler);
- }
-
public void changeRoleInConference(final Conversation conference, final String nick, MucOptions.Role role) {
IqPacket request = this.mIqGenerator.changeRole(conference, nick, role.toString());
- Log.d(Config.LOGTAG, request.toString());
sendIqPacket(conference.getAccount(), request, (account, packet) -> {
if (packet.getType() != IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + " unable to change role of " + nick);
@@ -3928,9 +3918,13 @@ public class XmppConnectionService extends Service {
new Thread(() -> reconnectAccount(account, false, true)).start();
}
- public void invite(Conversation conversation, Jid contact) {
+ public void invite(final Conversation conversation, final Jid contact) {
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": inviting " + contact + " to " + conversation.getJid().asBareJid());
- MessagePacket packet = mMessageGenerator.invite(conversation, contact);
+ final MucOptions.User user = conversation.getMucOptions().findUserByRealJid(contact.asBareJid());
+ if (user == null || user.getAffiliation() == MucOptions.Affiliation.OUTCAST) {
+ changeAffiliationInConference(conversation, contact, MucOptions.Affiliation.NONE, null);
+ }
+ final MessagePacket packet = mMessageGenerator.invite(conversation, contact);
sendMessagePacket(conversation.getAccount(), packet);
}