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
c6dc730b
Commit
c6dc730b
authored
Nov 02, 2017
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
584598fd
042a26d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
44 deletions
+96
-44
CHANGES.md
CHANGES.md
+4
-0
docs/source/developer_api.rst
docs/source/developer_api.rst
+37
-0
src/converse-disco.js
src/converse-disco.js
+41
-4
src/converse-mam.js
src/converse-mam.js
+14
-40
No files found.
CHANGES.md
View file @
c6dc730b
...
...
@@ -22,6 +22,10 @@
builds. Instead the
`converse.js`
build is now used with
`view_mode`
set to
`fullscreen`
and
`mobile`
respectively.
### API changes
-
New API method
`_converse.disco.supports`
to check whether a certain
service discovery feature is supported by an entity.
### UX/UI changes
-
Use CSS3 fade transitions to render various elements.
-
Remove
`Login`
and
`Registration`
tabs and consolidate into one panel.
...
...
docs/source/developer_api.rst
View file @
c6dc730b
...
...
@@ -431,6 +431,43 @@ disconnect
Terminates the connection.
The **disco** grouping
----------------------
This grouping collects API functions related to `service discovery
<https://xmpp.org/extensions/xep-0030.html>`_.
supports
~~~~~~~~
Used to determine whether an entity supports a given feature.
.. code-block:: javascript
converse.plugins.add('myplugin', {
initialize: function () {
_converse.api.disco.supports(_converse.bare_jid, Strophe.NS.MAM).then(
function (supported) {
if (supported) {
// The feature is supported
} else {
// The feature is not supported
}
},
function () { // Error
_converse.log(
"Error or timeout while checking for feature support",
Strophe.LogLevel.ERROR
);
}
).catch((msg) => {
_converse.log(msg, Strophe.LogLevel.FATAL);
});
}
});
The **user** grouping
---------------------
...
...
src/converse-disco.js
View file @
c6dc730b
...
...
@@ -42,10 +42,10 @@
_converse
.
DiscoEntity
=
Backbone
.
Model
.
extend
({
/* A Disco Entity is a JID addressable entity that can be queried
* for features.
*
* See XEP-0030: https://xmpp.org/extensions/xep-0030.html
*/
* for features.
*
* See XEP-0030: https://xmpp.org/extensions/xep-0030.html
*/
idAttribute
:
'
jid
'
,
initialize
()
{
...
...
@@ -178,6 +178,43 @@
_converse
.
disco_entities
.
browserStorage
.
_clear
();
}
});
/* We extend the default converse.js API to add methods specific to service discovery */
_
.
extend
(
_converse
.
api
,
{
'
disco
'
:
{
'
supports
'
(
entity_jid
,
feature
)
{
/* Returns a Promise which returns a boolean indicating
* whether the feature is supported or by the given
* entity or not.
*
* Parameters:
* (String) entity_jid - The JID of the entity which might support the feature.
* (String) feature - The feature that might be
* supported. In the XML stanza, this is the `var`
* attribute of the `<feature>` element. For
* example: 'http://jabber.org/protocol/muc'
*/
return
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
).
then
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
function
fulfillPromise
(
entity
)
{
if
(
entity
.
features
.
findWhere
({
'
var
'
:
feature
}))
{
resolve
(
true
);
}
else
{
resolve
(
false
);
}
}
let
entity
=
_converse
.
disco_entities
.
get
(
entity_jid
);
if
(
_
.
isUndefined
(
entity
))
{
entity
=
_converse
.
disco_entities
.
create
({
'
jid
'
:
entity_jid
});
entity
.
on
(
'
featuresDiscovered
'
,
_
.
partial
(
fulfillPromise
,
entity
));
}
else
{
fulfillPromise
(
entity
);
}
})
);
}
}
});
}
});
}));
src/converse-mam.js
View file @
c6dc730b
...
...
@@ -24,32 +24,6 @@
// XEP-0313 Message Archive Management
const
MAM_ATTRIBUTES
=
[
'
with
'
,
'
start
'
,
'
end
'
];
function
checkMAMSupport
(
_converse
)
{
/* Returns a promise which resolves when MAM is supported
* for this user, or which rejects if not.
*/
return
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
).
then
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
function
fulfillPromise
(
entity
)
{
if
(
entity
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
resolve
(
true
);
}
else
{
resolve
(
false
);
}
}
let
entity
=
_converse
.
disco_entities
.
get
(
_converse
.
bare_jid
);
if
(
_
.
isUndefined
(
entity
))
{
entity
=
_converse
.
disco_entities
.
create
({
'
jid
'
:
_converse
.
bare_jid
});
entity
.
on
(
'
featuresDiscovered
'
,
_
.
partial
(
fulfillPromise
,
entity
));
}
else
{
fulfillPromise
(
entity
);
}
})
);
}
converse
.
plugins
.
add
(
'
converse-mam
'
,
{
overrides
:
{
...
...
@@ -83,7 +57,7 @@
const
{
_converse
}
=
this
.
__super__
;
this
.
addSpinner
();
checkMAMSupport
(
_converse
).
then
(
_converse
.
api
.
disco
.
supports
(
_converse
.
bare_jid
,
Strophe
.
NS
.
MAM
).
then
(
(
supported
)
=>
{
// Success
if
(
supported
)
{
this
.
fetchArchivedMessages
();
...
...
@@ -329,19 +303,6 @@
);
};
_
.
extend
(
_converse
.
api
,
{
/* Extend default converse.js API to add methods specific to MAM
*/
'
archive
'
:
{
'
query
'
:
function
()
{
if
(
!
_converse
.
api
.
connection
.
connected
())
{
throw
new
Error
(
'
Can
\'
t call `api.archive.query` before having established an XMPP session
'
);
}
return
_converse
.
queryForArchivedMessages
.
apply
(
this
,
arguments
);
}
}
});
_converse
.
onMAMError
=
function
(
iq
)
{
if
(
$
(
iq
).
find
(
'
feature-not-implemented
'
).
length
)
{
_converse
.
log
(
...
...
@@ -409,6 +370,19 @@
_converse
.
on
(
'
afterMessagesFetched
'
,
(
chatboxview
)
=>
{
chatboxview
.
fetchArchivedMessagesIfNecessary
();
});
_
.
extend
(
_converse
.
api
,
{
/* Extend default converse.js API to add methods specific to MAM
*/
'
archive
'
:
{
'
query
'
:
function
()
{
if
(
!
_converse
.
api
.
connection
.
connected
())
{
throw
new
Error
(
'
Can
\'
t call `api.archive.query` before having established an XMPP session
'
);
}
return
_converse
.
queryForArchivedMessages
.
apply
(
this
,
arguments
);
}
}
});
}
});
}));
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