diff --git a/docs/Supported_XEP_Formats.md b/docs/Supported_XEP_Formats.md index b0f2c333..6d3cb199 100644 --- a/docs/Supported_XEP_Formats.md +++ b/docs/Supported_XEP_Formats.md @@ -90,7 +90,7 @@ | [XEP-0320](https://xmpp.org/extensions/xep-0320.html) | Use of DTLS-SRTP in Jingle Sessions | 0.3.1 | [Source](../src/protocol/xep0320.ts) | | | [XEP-0333](https://xmpp.org/extensions/xep-0333.html) | Chat Markers | 0.3.0 | [Source](../src/protocol/xep0333.ts) | [Test Cases](../test/protocol-cases/xep0333) | | [XEP-0334](https://xmpp.org/extensions/xep-0334.html) | Message Processing Hints | 0.3.0 | [Source](../src/protocol/xep0334.ts) | [Test Cases](../test/protocol-cases/xep0334) | -| [XEP-0335](https://xmpp.org/extensions/xep-0335.html) | JSON Containers | 0.1 | [Source](../src/protocol/xep0335.ts) | | +| [XEP-0335](https://xmpp.org/extensions/xep-0335.html) | JSON Containers | 0.1 | [Source](../src/protocol/xep0335.ts) | [Test Cases](../test/protocol-cases/xep0335) | | [XEP-0339](https://xmpp.org/extensions/xep-0339.html) | Source-Specific Media Attributes in Jingle | 0.1 | [Source](../src/protocol/xep0167.ts) | [Test Cases](../test/protocol-cases/xep0167) | | [XEP-0350](https://xmpp.org/extensions/xep-0350.html) | Data Forms Geolocation Element | 0.2 | [Source](../src/protocol/xep0080.ts) | | | [XEP-0352](https://xmpp.org/extensions/xep-0352.html) | Client State Indication | 0.2.1 | [Source](../src/protocol/xep0352.ts) | | diff --git a/src/protocol/xep0335.ts b/src/protocol/xep0335.ts index c41bb255..ab688d5d 100644 --- a/src/protocol/xep0335.ts +++ b/src/protocol/xep0335.ts @@ -5,7 +5,13 @@ // Version: 0.1 (2013-10-25) // ==================================================================== -import { childJSON, DefinitionOptions, extendMessage, pubsubItemContentAliases } from '../jxt'; +import { + childJSON, + DefinitionOptions, + extendMessage, + pubsubItemContentAliases, + textJSON +} from '../jxt'; import { NS_JSON_0 } from '../Namespaces'; import { PubsubItemContent } from './'; @@ -29,7 +35,7 @@ const Protocol: DefinitionOptions[] = [ aliases: pubsubItemContentAliases(), element: 'json', fields: { - json: childJSON(NS_JSON_0, 'json') + json: textJSON() }, namespace: NS_JSON_0, type: NS_JSON_0 diff --git a/test/protocol-cases/xep0335/message.json b/test/protocol-cases/xep0335/message.json new file mode 100644 index 00000000..7b4af84b --- /dev/null +++ b/test/protocol-cases/xep0335/message.json @@ -0,0 +1,14 @@ +[ + "message", + { + "from": "pubsub.shakespeare.lit", + "to": "francisco@denmark.lit", + "id": "foo", + "lang": "", + "json": { + "name": "romeo", + "age": "421", + "status": "single" + } + } +] diff --git a/test/protocol-cases/xep0335/message.xml b/test/protocol-cases/xep0335/message.xml new file mode 100644 index 00000000..0bce569d --- /dev/null +++ b/test/protocol-cases/xep0335/message.xml @@ -0,0 +1,3 @@ + + {"name":"romeo","age":"421","status":"single"} + diff --git a/test/protocol-cases/xep0335/pubsub-event.json b/test/protocol-cases/xep0335/pubsub-event.json new file mode 100644 index 00000000..55bc4c06 --- /dev/null +++ b/test/protocol-cases/xep0335/pubsub-event.json @@ -0,0 +1,55 @@ +[ + "message", + { + "from": "pubsub.shakespeare.lit", + "id": "foo", + "lang": "", + "pubsub": { + "context": "event", + "items": { + "node": "princely_musings", + "published": [ + { + "content": { + "itemType": "urn:xmpp:json:0", + "json": { + "age": "421", + "name": "romeo", + "status": "single" + } + }, + "id": "ae890ac52d0df67ed7cfdf51b644e901" + } + ] + } + }, + "to": "francisco@denmark.lit" + }, + { + "from": "pubsub.shakespeare.lit", + "id": "foo", + "lang": "", + "pubsub": { + "context": "event", + "eventType": "items", + "items": { + "node": "princely_musings", + "published": [ + { + "content": { + "itemType": "urn:xmpp:json:0", + "json": { + "age": "421", + "name": "romeo", + "status": "single" + } + }, + "id": "ae890ac52d0df67ed7cfdf51b644e901" + } + ], + "retracted": [] + } + }, + "to": "francisco@denmark.lit" + } +] diff --git a/test/protocol-cases/xep0335/pubsub-event.xml b/test/protocol-cases/xep0335/pubsub-event.xml new file mode 100644 index 00000000..40400c54 --- /dev/null +++ b/test/protocol-cases/xep0335/pubsub-event.xml @@ -0,0 +1,9 @@ + + + + + {"age":"421","name":"romeo","status":"single"} + + + + \ No newline at end of file