Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
e6c66cfe
Commit
e6c66cfe
authored
Dec 21, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ability to republish if publish-options precondition not met
parent
bcb3bcaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
10 deletions
+52
-10
dist/converse.js
dist/converse.js
+24
-5
src/converse-omemo.js
src/converse-omemo.js
+1
-1
src/headless/converse-pubsub.js
src/headless/converse-pubsub.js
+27
-4
No files found.
dist/converse.js
View file @
e6c66cfe
...
...
@@ -56807,7 +56807,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
const options = {
'pubsub#access_model': 'open'
};
return _converse.api.pubsub.publish(null, node, item, options);
return _converse.api.pubsub.publish(null, node, item, options
, false
);
},
async generateMissingPreKeys() {
...
...
@@ -67910,9 +67910,13 @@ _converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins.add('converse-pub
* @param {string} node The node being published to
* @param {Strophe.Builder} item The Strophe.Builder representation of the XML element being published
* @param {object} options An object representing the publisher options
* (see https://xmpp.org/extensions/xep-0060.html#publisher-publish-options)
* (see https://xmpp.org/extensions/xep-0060.html#publisher-publish-options)
* @param {boolean} strict_options Indicates whether the publisher
* options are a strict requirement or not. If they're NOT
* strict, then Converse will publish to the node even if
* the publish options precondication cannot be met.
*/
async 'publish'(jid, node, item, options) {
async 'publish'(jid, node, item, options
, strict_options = true
) {
const stanza = $iq({
'from': _converse.bare_jid,
'type': 'set',
...
...
@@ -67934,7 +67938,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins.add('converse-pub
}).c('field', {
'var': 'FORM_TYPE',
'type': 'hidden'
}).c('value').t(
'http://jabber.org/protocol/pubsub#publish-options'
).up().up();
}).c('value').t(
`${Strophe.NS.PUBSUB}#publish-options`
).up().up();
Object.keys(options).forEach(k => stanza.c('field', {
'var': k
}).c('value').t(options[k]).up().up());
...
...
@@ -67943,7 +67947,22 @@ _converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins.add('converse-pub
}
}
return _converse.api.sendIQ(stanza);
try {
_converse.api.sendIQ(stanza);
} catch (iq) {
if (iq instanceof Element && strict_options && iq.querySelector(`precondition-not-met[xmlns="${Strophe.NS.PUBSUB_ERROR}"]`)) {
// The publish-options precondition couldn't be
// met. We re-publish but without publish-options.
const el = stanza.nodeTree;
el.querySelector('publish-options').outerHTML = '';
_converse.log(`PubSub: Republishing without publish options. ${el.outerHTML}`, Strophe.LogLevel.WARN);
_converse.api.sendIQ(el);
} else {
throw iq;
}
}
}
}
src/converse-omemo.js
View file @
e6c66cfe
...
...
@@ -805,7 +805,7 @@ converse.plugins.add('converse-omemo', {
(
prekey
,
id
)
=>
item
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
id
}).
t
(
prekey
.
pubKey
).
up
()
);
const
options
=
{
'
pubsub#access_model
'
:
'
open
'
};
return
_converse
.
api
.
pubsub
.
publish
(
null
,
node
,
item
,
options
);
return
_converse
.
api
.
pubsub
.
publish
(
null
,
node
,
item
,
options
,
false
);
},
async
generateMissingPreKeys
()
{
...
...
src/headless/converse-pubsub.js
View file @
e6c66cfe
...
...
@@ -42,9 +42,13 @@ converse.plugins.add('converse-pubsub', {
* @param {string} node The node being published to
* @param {Strophe.Builder} item The Strophe.Builder representation of the XML element being published
* @param {object} options An object representing the publisher options
* (see https://xmpp.org/extensions/xep-0060.html#publisher-publish-options)
* (see https://xmpp.org/extensions/xep-0060.html#publisher-publish-options)
* @param {boolean} strict_options Indicates whether the publisher
* options are a strict requirement or not. If they're NOT
* strict, then Converse will publish to the node even if
* the publish options precondication cannot be met.
*/
async
'
publish
'
(
jid
,
node
,
item
,
options
)
{
async
'
publish
'
(
jid
,
node
,
item
,
options
,
strict_options
=
true
)
{
const
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
type
'
:
'
set
'
,
...
...
@@ -60,7 +64,7 @@ converse.plugins.add('converse-pubsub', {
stanza
.
c
(
'
publish-options
'
)
.
c
(
'
x
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
XFORM
,
'
type
'
:
'
submit
'
})
.
c
(
'
field
'
,
{
'
var
'
:
'
FORM_TYPE
'
,
'
type
'
:
'
hidden
'
})
.
c
(
'
value
'
).
t
(
'
http://jabber.org/protocol/pubsub#publish-options
'
).
up
().
up
()
.
c
(
'
value
'
).
t
(
`
${
Strophe
.
NS
.
PUBSUB
}
#publish-options`
).
up
().
up
()
Object
.
keys
(
options
).
forEach
(
k
=>
stanza
.
c
(
'
field
'
,
{
'
var
'
:
k
}).
c
(
'
value
'
).
t
(
options
[
k
]).
up
().
up
());
}
else
{
...
...
@@ -68,7 +72,26 @@ converse.plugins.add('converse-pubsub', {
`so we didn't set them even though they were provided.`
)
}
}
return
_converse
.
api
.
sendIQ
(
stanza
);
try
{
_converse
.
api
.
sendIQ
(
stanza
);
}
catch
(
iq
)
{
if
(
iq
instanceof
Element
&&
strict_options
&&
iq
.
querySelector
(
`precondition-not-met[xmlns="
${
Strophe
.
NS
.
PUBSUB_ERROR
}
"]`
))
{
// The publish-options precondition couldn't be
// met. We re-publish but without publish-options.
const
el
=
stanza
.
nodeTree
;
el
.
querySelector
(
'
publish-options
'
).
outerHTML
=
''
;
_converse
.
log
(
`PubSub: Republishing without publish options.
${
el
.
outerHTML
}
`
,
Strophe
.
LogLevel
.
WARN
);
_converse
.
api
.
sendIQ
(
el
);
}
else
{
throw
iq
;
}
}
}
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment