Commit 3f30d683 authored by Tom Evans's avatar Tom Evans

OF-562: Fix persistence for MUC room broadcast

Ensure "bits" are present by zero-padding the broadcast roles string
parent de468799
...@@ -206,14 +206,14 @@ public class MUCPersistenceManager { ...@@ -206,14 +206,14 @@ public class MUCPersistenceManager {
room.setLogEnabled(rs.getInt(16) == 1); room.setLogEnabled(rs.getInt(16) == 1);
room.setSubject(rs.getString(17)); room.setSubject(rs.getString(17));
List<String> rolesToBroadcast = new ArrayList<String>(); List<String> rolesToBroadcast = new ArrayList<String>();
String roles = Integer.toBinaryString(rs.getInt(18)); String roles = StringUtils.zeroPadString(Integer.toBinaryString(rs.getInt(18)), 3);
if (roles.charAt(0) == '1') { if (roles.charAt(0) == '1') {
rolesToBroadcast.add("moderator"); rolesToBroadcast.add("moderator");
} }
if (roles.length() > 1 && roles.charAt(1) == '1') { if (roles.charAt(1) == '1') {
rolesToBroadcast.add("participant"); rolesToBroadcast.add("participant");
} }
if (roles.length() > 2 && roles.charAt(2) == '1') { if (roles.charAt(2) == '1') {
rolesToBroadcast.add("visitor"); rolesToBroadcast.add("visitor");
} }
room.setRolesToBroadcastPresence(rolesToBroadcast); room.setRolesToBroadcastPresence(rolesToBroadcast);
...@@ -510,14 +510,14 @@ public class MUCPersistenceManager { ...@@ -510,14 +510,14 @@ public class MUCPersistenceManager {
room.setLogEnabled(resultSet.getInt(17) == 1); room.setLogEnabled(resultSet.getInt(17) == 1);
room.setSubject(resultSet.getString(18)); room.setSubject(resultSet.getString(18));
List<String> rolesToBroadcast = new ArrayList<String>(); List<String> rolesToBroadcast = new ArrayList<String>();
String roles = Integer.toBinaryString(resultSet.getInt(19)); String roles = StringUtils.zeroPadString(Integer.toBinaryString(resultSet.getInt(19)), 3);
if (roles.charAt(0) == '1') { if (roles.charAt(0) == '1') {
rolesToBroadcast.add("moderator"); rolesToBroadcast.add("moderator");
} }
if (roles.length() > 1 && roles.charAt(1) == '1') { if (roles.charAt(1) == '1') {
rolesToBroadcast.add("participant"); rolesToBroadcast.add("participant");
} }
if (roles.length() > 2 && roles.charAt(2) == '1') { if (roles.charAt(2) == '1') {
rolesToBroadcast.add("visitor"); rolesToBroadcast.add("visitor");
} }
room.setRolesToBroadcastPresence(rolesToBroadcast); room.setRolesToBroadcastPresence(rolesToBroadcast);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment