mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Fix sending pubsub events for empty item
XEP-0060 allows no elements on second level of nodes. Modified-by: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
parent
feff081547
commit
46f0110949
1 changed files with 10 additions and 0 deletions
|
@ -701,6 +701,7 @@ abstract public class Node
|
||||||
{
|
{
|
||||||
private final String firstElement;
|
private final String firstElement;
|
||||||
private final String secondElement;
|
private final String secondElement;
|
||||||
|
private final boolean allowEmpty;
|
||||||
|
|
||||||
EventContentFilter(String elementName)
|
EventContentFilter(String elementName)
|
||||||
{
|
{
|
||||||
|
@ -711,6 +712,8 @@ abstract public class Node
|
||||||
{
|
{
|
||||||
firstElement = firstLevelEelement;
|
firstElement = firstLevelEelement;
|
||||||
secondElement = secondLevelElement;
|
secondElement = secondLevelElement;
|
||||||
|
allowEmpty = firstElement.equals(EventElementType.items.toString())
|
||||||
|
&& "item".equals(secondLevelElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptSpecific(Message message) {
|
public boolean acceptSpecific(Message message) {
|
||||||
|
@ -736,6 +739,13 @@ abstract public class Node
|
||||||
{
|
{
|
||||||
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
|
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
|
||||||
|
|
||||||
|
// XEP-0060 allows no elements on second level for notifications. See schema or
|
||||||
|
// for example § 4.3:
|
||||||
|
// "although event notifications MUST include an empty <items/> element;"
|
||||||
|
if (allowEmpty && secondLevelList.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
|
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue