mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 13:07:59 +01:00
Make IQReplyFilter aware of user-less connection state
SMACK-533
This commit is contained in:
parent
a7ec0338bc
commit
1f2183605c
1 changed files with 10 additions and 3 deletions
|
@ -80,7 +80,13 @@ public class IQReplyFilter implements PacketFilter {
|
||||||
*/
|
*/
|
||||||
public IQReplyFilter(IQ iqPacket, Connection conn) {
|
public IQReplyFilter(IQ iqPacket, Connection conn) {
|
||||||
to = iqPacket.getTo();
|
to = iqPacket.getTo();
|
||||||
local = conn.getUser().toLowerCase();
|
if (conn.getUser() == null) {
|
||||||
|
// We have not yet been assigned a username, this can happen if the connection is
|
||||||
|
// in an early stage, i.e. when performing the SASL auth.
|
||||||
|
local = null;
|
||||||
|
} else {
|
||||||
|
local = conn.getUser().toLowerCase();
|
||||||
|
}
|
||||||
server = conn.getServiceName().toLowerCase();
|
server = conn.getServiceName().toLowerCase();
|
||||||
packetId = iqPacket.getPacketID();
|
packetId = iqPacket.getPacketID();
|
||||||
|
|
||||||
|
@ -89,10 +95,11 @@ public class IQReplyFilter implements PacketFilter {
|
||||||
OrFilter fromFilter = new OrFilter();
|
OrFilter fromFilter = new OrFilter();
|
||||||
fromFilter.addFilter(FromMatchesFilter.createFull(to));
|
fromFilter.addFilter(FromMatchesFilter.createFull(to));
|
||||||
if (to == null) {
|
if (to == null) {
|
||||||
fromFilter.addFilter(FromMatchesFilter.createBare(local));
|
if (local != null)
|
||||||
|
fromFilter.addFilter(FromMatchesFilter.createBare(local));
|
||||||
fromFilter.addFilter(FromMatchesFilter.createFull(server));
|
fromFilter.addFilter(FromMatchesFilter.createFull(server));
|
||||||
}
|
}
|
||||||
else if (to.toLowerCase().equals(StringUtils.parseBareAddress(local))) {
|
else if (local != null && to.toLowerCase().equals(StringUtils.parseBareAddress(local))) {
|
||||||
fromFilter.addFilter(FromMatchesFilter.createFull(null));
|
fromFilter.addFilter(FromMatchesFilter.createFull(null));
|
||||||
}
|
}
|
||||||
filter = new AndFilter(fromFilter, iqFilter, idFilter);
|
filter = new AndFilter(fromFilter, iqFilter, idFilter);
|
||||||
|
|
Loading…
Reference in a new issue