fixed some extended muc info handling. match what ejabberd does
This commit is contained in:
parent
159fedb358
commit
6c27d07803
|
@ -749,7 +749,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String prev = this.attributes.getString(key);
|
final String prev = this.attributes.optString(key, null);
|
||||||
this.attributes.put(key, value);
|
this.attributes.put(key, value);
|
||||||
return !value.equals(prev);
|
return !value.equals(prev);
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
this.attributes.put(key, array);
|
this.attributes.put(key, array);
|
||||||
return true;
|
return true;
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -777,11 +776,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
|
|
||||||
public String getAttribute(String key) {
|
public String getAttribute(String key) {
|
||||||
synchronized (this.attributes) {
|
synchronized (this.attributes) {
|
||||||
try {
|
return this.attributes.optString(key, null);
|
||||||
return this.attributes.getString(key);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.siacs.conversations.entities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -377,9 +378,10 @@ public class MucOptions {
|
||||||
public boolean updateConfiguration(ServiceDiscoveryResult serviceDiscoveryResult) {
|
public boolean updateConfiguration(ServiceDiscoveryResult serviceDiscoveryResult) {
|
||||||
this.serviceDiscoveryResult = serviceDiscoveryResult;
|
this.serviceDiscoveryResult = serviceDiscoveryResult;
|
||||||
String name;
|
String name;
|
||||||
Field roomInfoName = getRoomInfoForm().getFieldByName("muc#roominfo_name");
|
Field roomConfigName = getRoomInfoForm().getFieldByName("muc#roomconfig_roomname");
|
||||||
if (roomInfoName != null) {
|
if (roomConfigName != null) {
|
||||||
name = roomInfoName.getValue();
|
Log.d(Config.LOGTAG,"value of room config name "+roomConfigName.getValue());
|
||||||
|
name = roomConfigName.getValue();
|
||||||
} else {
|
} else {
|
||||||
List<ServiceDiscoveryResult.Identity> identities = serviceDiscoveryResult.getIdentities();
|
List<ServiceDiscoveryResult.Identity> identities = serviceDiscoveryResult.getIdentities();
|
||||||
String identityName = identities.size() > 0 ? identities.get(0).getName() : null;
|
String identityName = identities.size() > 0 ? identities.get(0).getName() : null;
|
||||||
|
@ -415,7 +417,7 @@ public class MucOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canInvite() {
|
public boolean canInvite() {
|
||||||
Field field = getRoomInfoForm().getFieldByName("muc#roominfo_allowinvites");
|
Field field = getRoomInfoForm().getFieldByName("muc#roomconfig_allowinvites");
|
||||||
return !membersOnly() || self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
return !membersOnly() || self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,8 +427,19 @@ public class MucOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowPm() {
|
public boolean allowPm() {
|
||||||
Field field = getRoomInfoForm().getFieldByName("muc#roominfo_allowpm");
|
final Field field = getRoomInfoForm().getFieldByName("muc#roomconfig_allowpm");
|
||||||
return field != null && "1".equals(field.getValue());
|
if (field == null) {
|
||||||
|
return true; //fall back if field does not exists
|
||||||
|
}
|
||||||
|
if ("anyone".equals(field.getValue())) {
|
||||||
|
return true;
|
||||||
|
} else if ("participants".equals(field.getValue())) {
|
||||||
|
return self.getRole().ranks(Role.PARTICIPANT);
|
||||||
|
} else if ("moderators".equals(field.getValue())) {
|
||||||
|
return self.getRole().ranks(Role.MODERATOR);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean participating() {
|
public boolean participating() {
|
||||||
|
|
Loading…
Reference in New Issue