Skip to content
Permalink
Browse files

Allow pulling reason text from child text of conf element.

Partially addresses #381 until a full solution is made.
  • Loading branch information...
legastero committed Sep 5, 2019
1 parent e408cb8 commit eca332771233b991fec08d308ff85dd944388f09
@@ -70,7 +70,7 @@
| [XEP-0231](https://xmpp.org/extensions/xep-0231.html) | Bits of Binary | 1.0 | [Source](../src/protocol/xep0231.ts) | |
| [XEP-0234](https://xmpp.org/extensions/xep-0234.html) | Jingle File Transfer | 0.18.3 | [Source](../src/protocol/xep0234.ts) | |
| [XEP-0247](https://xmpp.org/extensions/xep-0247.html) | Jingle XML Streams | 0.2 | [Source](../src/protocol/xep247.ts) | |
| [XEP-0249](https://xmpp.org/extensions/xep-0249.html) | Direct MUC Invitations | 1.2 | [Source](../src/protocol/xep0045.ts) | |
| [XEP-0249](https://xmpp.org/extensions/xep-0249.html) | Direct MUC Invitations | 1.2 | [Source](../src/protocol/xep0045.ts) | [Test Cases](../test/protocol-cases/xep0045) |
| [XEP-0256](https://xmpp.org/extensions/xep-0256.html) | Last Activity in Presence | 1.1 | [Source](../src/protocol/xep0012.ts) | [Test Cases](../test/protocol-cases/xep0012) |
| [XEP-0260](https://xmpp.org/extensions/xep-0260.html) | Jingle SOCKS5 Bytestreams Transport Method | 1.0.1 | [Source](../src/protocol/xep0260.ts) | |
| [XEP-0261](https://xmpp.org/extensions/xep-0261.html) | Jingle In-Band Bytestreams Transport Method | 1.0 | [Source](../src/protocol/xep0261.ts) | |
@@ -23,6 +23,7 @@ import { JID } from '../JID';
import {
addAlias,
attribute,
booleanAttribute,
childAttribute,
childBoolean,
childEnum,
@@ -155,6 +156,9 @@ export interface MUCUnique {
name?: string;
}

const reasonAttribute = attribute('reason');
const reasonText = text();

const Protocol: DefinitionOptions[] = [
addAlias(NS_DATAFORM, 'x', [{ path: 'iq.muc.form', selector: 'configure' }]),
{
@@ -293,10 +297,21 @@ const Protocol: DefinitionOptions[] = [
element: 'x',
fields: {
action: staticValue('invite'),
continue: attribute('continue'),
continue: booleanAttribute('continue'),
jid: JIDAttribute('jid'),
password: attribute('password'),
reason: attribute('reason'),
reason: {
importer(xml, context) {
const attr = reasonAttribute.importer(xml, context);
if (attr) {
return attr;
}
return reasonText.importer(xml, context);
},
exporter(xml, data, context) {
reasonAttribute.exporter(xml, data, context);
}
},
thread: attribute('thread')
},
namespace: NS_MUC_DIRECT_INVITE,
@@ -0,0 +1,17 @@
[
"message",
{
"from": "crone1@shakespeare.lit/desktop",
"lang": "",
"muc": {
"action": "invite",
"continue": true,
"jid": "darkcave@macbeth.shakespeare.lit",
"password": "cauldronburn",
"reason": "Hey Hecate, this is the place for all good witches!",
"thread": "e0ffe42b28561960c6b12b944a092794b9683a38",
"type": "direct-invite"
},
"to": "hecate@shakespeare.lit"
}
]
@@ -0,0 +1,10 @@
<message
from='crone1@shakespeare.lit/desktop'
to='hecate@shakespeare.lit'>
<x xmlns='jabber:x:conference'
continue='1'
jid='darkcave@macbeth.shakespeare.lit'
password='cauldronburn'
reason='Hey Hecate, this is the place for all good witches!'
thread='e0ffe42b28561960c6b12b944a092794b9683a38'/>
</message>

0 comments on commit eca3327

Please sign in to comment.
You can’t perform that action at this time.