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
e8a26eb1
Commit
e8a26eb1
authored
May 28, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store the roster version
updates #1106
parent
43d0932d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
11 deletions
+57
-11
spec/protocol.js
spec/protocol.js
+1
-1
spec/roster.js
spec/roster.js
+37
-0
src/converse-roster.js
src/converse-roster.js
+19
-10
No files found.
spec/protocol.js
View file @
e8a26eb1
...
@@ -210,7 +210,7 @@
...
@@ -210,7 +210,7 @@
* </iq>
* </iq>
*/
*/
spyOn
(
_converse
.
roster
,
"
updateContact
"
).
and
.
callThrough
();
spyOn
(
_converse
.
roster
,
"
updateContact
"
).
and
.
callThrough
();
stanza
=
$iq
({
'
type
'
:
'
set
'
,
'
from
'
:
'
dummy@localhost
'
})
stanza
=
$iq
({
'
type
'
:
'
set
'
,
'
from
'
:
_converse
.
connection
.
jid
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
jid
'
:
'
contact@example.org
'
,
'
jid
'
:
'
contact@example.org
'
,
...
...
spec/roster.js
View file @
e8a26eb1
...
@@ -35,6 +35,43 @@
...
@@ -35,6 +35,43 @@
describe
(
"
The Contacts Roster
"
,
function
()
{
describe
(
"
The Contacts Roster
"
,
function
()
{
it
(
"
supports roster versioning
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
var
stanza
;
test_utils
.
waitUntil
(()
=>
{
const
node
=
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
);
}).
pop
();
if
(
node
)
{
stanza
=
node
.
nodeTree
;
return
true
;
}
}).
then
(()
=>
{
expect
(
_converse
.
roster
.
data
.
get
(
'
version
'
)).
toBeUndefined
();
expect
(
stanza
.
outerHTML
).
toBe
(
`<iq type="get" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
const
result
=
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
stanza
.
getAttribute
(
'
id
'
)
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
,
'
ver
'
:
'
ver7
'
}).
c
(
'
item
'
,
{
'
jid
'
:
'
nurse@example.com
'
}).
up
()
.
c
(
'
item
'
,
{
'
jid
'
:
'
romeo@example.com
'
})
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
expect
(
_converse
.
roster
.
data
.
get
(
'
version
'
)).
toBe
(
'
ver7
'
);
done
();
});
}));
describe
(
"
The live filter
"
,
function
()
{
describe
(
"
The live filter
"
,
function
()
{
it
(
"
will only appear when roster contacts flow over the visible area
"
,
it
(
"
will only appear when roster contacts flow over the visible area
"
,
...
...
src/converse-roster.js
View file @
e8a26eb1
...
@@ -48,6 +48,13 @@
...
@@ -48,6 +48,13 @@
_converse
.
roster
=
new
_converse
.
RosterContacts
();
_converse
.
roster
=
new
_converse
.
RosterContacts
();
_converse
.
roster
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
_converse
.
storage
](
_converse
.
roster
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
_converse
.
storage
](
b64_sha1
(
`converse.contacts-
${
_converse
.
bare_jid
}
`
));
b64_sha1
(
`converse.contacts-
${
_converse
.
bare_jid
}
`
));
_converse
.
roster
.
data
=
new
Backbone
.
Model
();
const
id
=
b64_sha1
(
`converse-roster-model-
${
_converse
.
bare_jid
}
`
);
_converse
.
roster
.
data
.
id
=
id
;
_converse
.
roster
.
data
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
_converse
.
storage
](
id
);
_converse
.
roster
.
data
.
fetch
();
_converse
.
rostergroups
=
new
_converse
.
RosterGroups
();
_converse
.
rostergroups
=
new
_converse
.
RosterGroups
();
_converse
.
rostergroups
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
_converse
.
storage
](
_converse
.
rostergroups
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
_converse
.
storage
](
b64_sha1
(
`converse.roster.groups
${
_converse
.
bare_jid
}
`
));
b64_sha1
(
`converse.roster.groups
${
_converse
.
bare_jid
}
`
));
...
@@ -330,18 +337,18 @@
...
@@ -330,18 +337,18 @@
onConnected
()
{
onConnected
()
{
/* Called as soon as the connection has been established
/* Called as soon as the connection has been established
* (either after initial login, or after reconnection).
* (either after initial login, or after reconnection).
*
*
* Use the opportunity to register stanza handlers.
* Use the opportunity to register stanza handlers.
*/
*/
this
.
registerRosterHandler
();
this
.
registerRosterHandler
();
this
.
registerRosterXHandler
();
this
.
registerRosterXHandler
();
},
},
registerRosterHandler
()
{
registerRosterHandler
()
{
/* Register a handler for roster IQ "set" stanzas, which update
/* Register a handler for roster IQ "set" stanzas, which update
* roster contacts.
* roster contacts.
*/
*/
_converse
.
connection
.
addHandler
((
iq
)
=>
{
_converse
.
connection
.
addHandler
((
iq
)
=>
{
_converse
.
roster
.
onRosterPush
(
iq
);
_converse
.
roster
.
onRosterPush
(
iq
);
return
true
;
return
true
;
...
@@ -350,8 +357,8 @@
...
@@ -350,8 +357,8 @@
registerRosterXHandler
()
{
registerRosterXHandler
()
{
/* Register a handler for RosterX message stanzas, which are
/* Register a handler for RosterX message stanzas, which are
* used to suggest roster contacts to a user.
* used to suggest roster contacts to a user.
*/
*/
let
t
=
0
;
let
t
=
0
;
_converse
.
connection
.
addHandler
(
_converse
.
connection
.
addHandler
(
function
(
msg
)
{
function
(
msg
)
{
...
@@ -560,8 +567,10 @@
...
@@ -560,8 +567,10 @@
/* An IQ stanza containing the roster has been received from
/* An IQ stanza containing the roster has been received from
* the XMPP server.
* the XMPP server.
*/
*/
const
items
=
sizzle
(
`query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"] item`
,
iq
);
const
query
=
sizzle
(
`query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
iq
).
pop
(),
_
.
each
(
items
,
this
.
updateContact
.
bind
(
this
));
items
=
sizzle
(
`item`
,
query
);
_
.
each
(
items
,
(
item
)
=>
this
.
updateContact
(
item
));
this
.
data
.
save
(
'
version
'
,
query
.
getAttribute
(
'
ver
'
));
_converse
.
emit
(
'
roster
'
,
iq
);
_converse
.
emit
(
'
roster
'
,
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