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
7b194832
Commit
7b194832
authored
Jun 11, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `push_services` to `push_app_servers` to avoid confusion
parent
907775d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
57 deletions
+57
-57
dist/converse.js
dist/converse.js
+25
-25
docs/source/configuration.rst
docs/source/configuration.rst
+2
-2
spec/push.js
spec/push.js
+5
-5
src/converse-push.js
src/converse-push.js
+25
-25
No files found.
dist/converse.js
View file @
7b194832
...
...
@@ -73353,64 +73353,64 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
__ = _converse.__;
_converse.api.settings.update({
'push_
service
s': []
'push_
app_server
s': []
});
function disablePush
Service(push_service
) {
if (!push_
service
.jid) {
function disablePush
AppServer(push_app_server
) {
if (!push_
app_server
.jid) {
return;
}
Promise.all([_converse.api.disco.supports(Strophe.NS.PUSH, _converse.bare_jid)]).then(result => {
if (!result[0].length && !result[1].length) {
return _converse.log(`Not disabling push
service "${push_service
.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
return _converse.log(`Not disabling push
app server "${push_app_server
.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
}
const stanza = $iq({
'type': 'set'
}).c('disable', {
'xmlns': Strophe.NS.PUSH,
'jid': push_
service
.jid
'jid': push_
app_server
.jid
});
if (push_
service
.node) {
if (push_
app_server
.node) {
stanza.attrs({
'node': push_
service
.node
'node': push_
app_server
.node
});
}
_converse.api.sendIQ(stanza).then(() => _converse.session.set('push_enabled', true)).catch(e => {
_converse.log(`Could not enable push
service for ${push_service
.jid}`, Strophe.LogLevel.ERROR);
_converse.log(`Could not enable push
app server for ${push_app_server
.jid}`, Strophe.LogLevel.ERROR);
_converse.log(e, Strophe.LogLevel.ERROR);
});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
function enablePush
Service(push_service
) {
if (!push_
service.jid || !push_service
.node) {
function enablePush
AppServer(push_app_server
) {
if (!push_
app_server.jid || !push_app_server
.node) {
return;
}
_converse.api.disco.getIdentity('pubsub', 'push', push_
service
.jid).then(identity => {
_converse.api.disco.getIdentity('pubsub', 'push', push_
app_server
.jid).then(identity => {
if (!identity) {
return _converse.log(`Not enabling push the service "${push_
service
.jid}", it doesn't have the right disco identtiy.`, Strophe.LogLevel.WARN);
return _converse.log(`Not enabling push the service "${push_
app_server
.jid}", it doesn't have the right disco identtiy.`, Strophe.LogLevel.WARN);
}
return Promise.all([_converse.api.disco.supports(Strophe.NS.PUSH, push_
service
.jid), _converse.api.disco.supports(Strophe.NS.PUSH, _converse.bare_jid)]).then(result => {
return Promise.all([_converse.api.disco.supports(Strophe.NS.PUSH, push_
app_server
.jid), _converse.api.disco.supports(Strophe.NS.PUSH, _converse.bare_jid)]).then(result => {
if (!result[0].length && !result[1].length) {
return _converse.log(`Not enabling push
service "${push_service
.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
return _converse.log(`Not enabling push
app server "${push_app_server
.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
}
const stanza = $iq({
'type': 'set'
}).c('enable', {
'xmlns': Strophe.NS.PUSH,
'jid': push_
service
.jid,
'node': push_
service
.node
'jid': push_
app_server
.jid,
'node': push_
app_server
.node
});
if (push_
service
.secret) {
if (push_
app_server
.secret) {
stanza.c('x', {
'xmlns': Strophe.NS.XFORM,
'type': 'submit'
...
...
@@ -73418,11 +73418,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'var': 'FORM_TYPE'
}).c('value').t(`${Strophe.NS.PUBSUB}#publish-options`).up().up().c('field', {
'var': 'secret'
}).c('value').t(push_
service
.secret);
}).c('value').t(push_
app_server
.secret);
}
_converse.api.sendIQ(stanza).then(() => _converse.session.set('push_enabled', true)).catch(e => {
_converse.log(`Could not enable push
service for ${push_service
.jid}`, Strophe.LogLevel.ERROR);
_converse.log(`Could not enable push
app server for ${push_app_server
.jid}`, Strophe.LogLevel.ERROR);
_converse.log(e, Strophe.LogLevel.ERROR);
});
...
...
@@ -73433,20 +73433,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
function enablePush() {
if (_converse.session.get('push_enabled')) {
// XXX: this code is still a bit naive. We set push_enabled
// to true as soon as the first push
service
has been set.
// to true as soon as the first push
app server
has been set.
//
// When enabling or disabling multiple push
service
s,
// When enabling or disabling multiple push
app server
s,
// we won't wait until we have confirmation that all have been set.
return;
}
const enabled_services = _.reject(_converse.push_
service
s, 'disable');
const enabled_services = _.reject(_converse.push_
app_server
s, 'disable');
_.each(enabled_services, enablePush
Service
);
_.each(enabled_services, enablePush
AppServer
);
const disabled_services = _.filter(_converse.push_
service
s, 'disable');
const disabled_services = _.filter(_converse.push_
app_server
s, 'disable');
_.each(disabled_services, disablePush
Service
);
_.each(disabled_services, disablePush
AppServer
);
}
_converse.api.listen.on('statusInitialized', enablePush);
docs/source/configuration.rst
View file @
7b194832
...
...
@@ -1068,7 +1068,7 @@ providers_link
The hyperlink on the registration form which points to a directory of public
XMPP servers.
push_
service
s
push_
app_server
s
-------------
* Default: ``[]``
...
...
@@ -1091,7 +1091,7 @@ For example:
.. code-block:: javascript
converse.initialize({
'push_
service
s': [{
'push_
app_server
s': [{
'jid': 'push-4@client.example',
'node': 'yxs32uqsflafdk3iuqo',
'disable': true
...
...
spec/push.js
View file @
7b194832
...
...
@@ -11,7 +11,7 @@
it
(
"
can be enabled
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
push_
service
s
'
:
[{
'
push_
app_server
s
'
:
[{
'
jid
'
:
'
push-5@client.example
'
,
'
node
'
:
'
yxs32uqsflafdk3iuqo
'
}]
...
...
@@ -23,7 +23,7 @@
expect
(
_converse
.
session
.
get
(
'
push_enabled
'
)).
toBeFalsy
();
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
push_
service
s
[
0
].
jid
,
_converse
,
_converse
.
push_
app_server
s
[
0
].
jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
push
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
)
.
then
(()
=>
test_utils
.
waitUntilDiscoConfirmed
(
...
...
@@ -61,7 +61,7 @@
it
(
"
can be disabled
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
push_
service
s
'
:
[{
'
push_
app_server
s
'
:
[{
'
jid
'
:
'
push-5@client.example
'
,
'
node
'
:
'
yxs32uqsflafdk3iuqo
'
,
'
disable
'
:
true
...
...
@@ -109,7 +109,7 @@
it
(
"
can require a secret token to be included
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
push_
service
s
'
:
[{
'
push_
app_server
s
'
:
[{
'
jid
'
:
'
push-5@client.example
'
,
'
node
'
:
'
yxs32uqsflafdk3iuqo
'
,
'
secret
'
:
'
eruio234vzxc2kla-91
'
...
...
@@ -121,7 +121,7 @@
expect
(
_converse
.
session
.
get
(
'
push_enabled
'
)).
toBeFalsy
();
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
push_
service
s
[
0
].
jid
,
_converse
,
_converse
.
push_
app_server
s
[
0
].
jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
push
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
)
.
then
(()
=>
test_utils
.
waitUntilDiscoConfirmed
(
...
...
src/converse-push.js
View file @
7b194832
...
...
@@ -27,11 +27,11 @@
{
__
}
=
_converse
;
_converse
.
api
.
settings
.
update
({
'
push_
service
s
'
:
[],
'
push_
app_server
s
'
:
[],
});
function
disablePush
Service
(
push_service
)
{
if
(
!
push_
service
.
jid
)
{
function
disablePush
AppServer
(
push_app_server
)
{
if
(
!
push_
app_server
.
jid
)
{
return
;
}
Promise
.
all
([
...
...
@@ -39,67 +39,67 @@
]).
then
((
result
)
=>
{
if
(
!
result
[
0
].
length
&&
!
result
[
1
].
length
)
{
return
_converse
.
log
(
`Not disabling push
service "
${
push_service
.
jid
}
", no disco support from your server.`
,
`Not disabling push
app server "
${
push_app_server
.
jid
}
", no disco support from your server.`
,
Strophe
.
LogLevel
.
WARN
);
}
const
stanza
=
$iq
({
'
type
'
:
'
set
'
})
.
c
(
'
disable
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
PUSH
,
'
jid
'
:
push_
service
.
jid
,
'
jid
'
:
push_
app_server
.
jid
,
});
if
(
push_
service
.
node
)
{
stanza
.
attrs
({
'
node
'
:
push_
service
.
node
});
if
(
push_
app_server
.
node
)
{
stanza
.
attrs
({
'
node
'
:
push_
app_server
.
node
});
}
_converse
.
api
.
sendIQ
(
stanza
)
.
then
(()
=>
_converse
.
session
.
set
(
'
push_enabled
'
,
true
))
.
catch
((
e
)
=>
{
_converse
.
log
(
`Could not enable push
service for
${
push_service
.
jid
}
`
,
Strophe
.
LogLevel
.
ERROR
);
_converse
.
log
(
`Could not enable push
app server for
${
push_app_server
.
jid
}
`
,
Strophe
.
LogLevel
.
ERROR
);
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
});
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}
function
enablePush
Service
(
push_service
)
{
if
(
!
push_
service
.
jid
||
!
push_service
.
node
)
{
function
enablePush
AppServer
(
push_app_server
)
{
if
(
!
push_
app_server
.
jid
||
!
push_app_server
.
node
)
{
return
;
}
_converse
.
api
.
disco
.
getIdentity
(
'
pubsub
'
,
'
push
'
,
push_
service
.
jid
)
_converse
.
api
.
disco
.
getIdentity
(
'
pubsub
'
,
'
push
'
,
push_
app_server
.
jid
)
.
then
((
identity
)
=>
{
if
(
!
identity
)
{
return
_converse
.
log
(
`Not enabling push the service "
${
push_
service
.
jid
}
", it doesn't have the right disco identtiy.`
,
`Not enabling push the service "
${
push_
app_server
.
jid
}
", it doesn't have the right disco identtiy.`
,
Strophe
.
LogLevel
.
WARN
);
}
return
Promise
.
all
([
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
PUSH
,
push_
service
.
jid
),
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
PUSH
,
push_
app_server
.
jid
),
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
PUSH
,
_converse
.
bare_jid
)
]).
then
((
result
)
=>
{
if
(
!
result
[
0
].
length
&&
!
result
[
1
].
length
)
{
return
_converse
.
log
(
`Not enabling push
service "
${
push_service
.
jid
}
", no disco support from your server.`
,
`Not enabling push
app server "
${
push_app_server
.
jid
}
", no disco support from your server.`
,
Strophe
.
LogLevel
.
WARN
);
}
const
stanza
=
$iq
({
'
type
'
:
'
set
'
})
.
c
(
'
enable
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
PUSH
,
'
jid
'
:
push_
service
.
jid
,
'
node
'
:
push_
service
.
node
'
jid
'
:
push_
app_server
.
jid
,
'
node
'
:
push_
app_server
.
node
});
if
(
push_
service
.
secret
)
{
if
(
push_
app_server
.
secret
)
{
stanza
.
c
(
'
x
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
XFORM
,
'
type
'
:
'
submit
'
})
.
c
(
'
field
'
,
{
'
var
'
:
'
FORM_TYPE
'
})
.
c
(
'
value
'
).
t
(
`
${
Strophe
.
NS
.
PUBSUB
}
#publish-options`
).
up
().
up
()
.
c
(
'
field
'
,
{
'
var
'
:
'
secret
'
})
.
c
(
'
value
'
).
t
(
push_
service
.
secret
);
.
c
(
'
value
'
).
t
(
push_
app_server
.
secret
);
}
_converse
.
api
.
sendIQ
(
stanza
)
.
then
(()
=>
_converse
.
session
.
set
(
'
push_enabled
'
,
true
))
.
catch
((
e
)
=>
{
_converse
.
log
(
`Could not enable push
service for
${
push_service
.
jid
}
`
,
Strophe
.
LogLevel
.
ERROR
);
_converse
.
log
(
`Could not enable push
app server for
${
push_app_server
.
jid
}
`
,
Strophe
.
LogLevel
.
ERROR
);
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
});
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
...
...
@@ -109,17 +109,17 @@
function
enablePush
()
{
if
(
_converse
.
session
.
get
(
'
push_enabled
'
))
{
// XXX: this code is still a bit naive. We set push_enabled
// to true as soon as the first push
service
has been set.
// to true as soon as the first push
app server
has been set.
//
// When enabling or disabling multiple push
service
s,
// When enabling or disabling multiple push
app server
s,
// we won't wait until we have confirmation that all have been set.
return
;
}
const
enabled_services
=
_
.
reject
(
_converse
.
push_
service
s
,
'
disable
'
);
_
.
each
(
enabled_services
,
enablePush
Service
);
const
enabled_services
=
_
.
reject
(
_converse
.
push_
app_server
s
,
'
disable
'
);
_
.
each
(
enabled_services
,
enablePush
AppServer
);
const
disabled_services
=
_
.
filter
(
_converse
.
push_
service
s
,
'
disable
'
);
_
.
each
(
disabled_services
,
disablePush
Service
);
const
disabled_services
=
_
.
filter
(
_converse
.
push_
app_server
s
,
'
disable
'
);
_
.
each
(
disabled_services
,
disablePush
AppServer
);
}
_converse
.
api
.
listen
.
on
(
'
statusInitialized
'
,
enablePush
);
}
...
...
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