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
fbef370b
Commit
fbef370b
authored
Feb 07, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Listen for new room bookmarks pushed from the user's PEP service
parent
5f3761dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
50 deletions
+76
-50
CHANGES.md
CHANGES.md
+1
-0
spec/bookmarks.js
spec/bookmarks.js
+53
-45
src/converse-bookmarks.js
src/converse-bookmarks.js
+22
-5
No files found.
CHANGES.md
View file @
fbef370b
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
### New features
### New features
-
XEP-0382 Spoiler Messages (currently only for private chats)
-
XEP-0382 Spoiler Messages (currently only for private chats)
-
Listen for new room bookmarks pushed from the user's PEP service.
### API changes
### API changes
-
New API method
`_converse.disco.getIdentity`
to check whether a JID has a given identity.
-
New API method
`_converse.disco.getIdentity`
to check whether a JID has a given identity.
...
...
spec/bookmarks.js
View file @
fbef370b
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
}
(
this
,
function
(
jasmine
,
$
,
converse
,
utils
,
mock
,
test_utils
)
{
}
(
this
,
function
(
jasmine
,
$
,
converse
,
utils
,
mock
,
test_utils
)
{
"
use strict
"
;
"
use strict
"
;
var
$iq
=
converse
.
env
.
$iq
,
var
$iq
=
converse
.
env
.
$iq
,
$msg
=
converse
.
env
.
$msg
,
Backbone
=
converse
.
env
.
Backbone
,
Backbone
=
converse
.
env
.
Backbone
,
Strophe
=
converse
.
env
.
Strophe
,
Strophe
=
converse
.
env
.
Strophe
,
_
=
converse
.
env
.
_
,
_
=
converse
.
env
.
_
,
...
@@ -278,51 +279,58 @@
...
@@ -278,51 +279,58 @@
describe
(
"
Bookmarks
"
,
function
()
{
describe
(
"
Bookmarks
"
,
function
()
{
xit
(
"
can be pushed from the XMPP server
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
can be pushed from the XMPP server
"
,
mock
.
initConverseWithPromises
(
// TODO
[
'
send
'
],
[
'
rosterGroupsFetched
'
,
'
connected
'
],
{},
/* The stored data is automatically pushed to all of the user's
function
(
done
,
_converse
)
{
* connected resources.
*
test_utils
.
openControlBox
().
openRoomsPanel
(
_converse
);
* Publisher receives event notification
* -------------------------------------
test_utils
.
waitUntil
(
function
()
{
* <message from='juliet@capulet.lit'
return
_converse
.
bookmarks
;
* to='juliet@capulet.lit/balcony'
},
300
).
then
(
function
()
{
* type='headline'
/* The stored data is automatically pushed to all of the user's
* id='rnfoo1'>
* connected resources.
* <event xmlns='http://jabber.org/protocol/pubsub#event'>
*
* <items node='storage:bookmarks'>
* Publisher receives event notification
* <item id='current'>
* -------------------------------------
* <storage xmlns='storage:bookmarks'>
* <message from='juliet@capulet.lit'
* <conference name='The Play's the Thing'
* to='juliet@capulet.lit/balcony'
* autojoin='true'
* type='headline'
* jid='theplay@conference.shakespeare.lit'>
* id='rnfoo1'>
* <nick>JC</nick>
* <event xmlns='http://jabber.org/protocol/pubsub#event'>
* </conference>
* <items node='storage:bookmarks'>
* </storage>
* <item id='current'>
* </item>
* <storage xmlns='storage:bookmarks'>
* </items>
* <conference name='The Play's the Thing'
* </event>
* autojoin='true'
* </message>
* jid='theplay@conference.shakespeare.lit'>
* <nick>JC</nick>
* <message from='juliet@capulet.lit'
* </conference>
* to='juliet@capulet.lit/chamber'
* </storage>
* type='headline'
* </item>
* id='rnfoo2'>
* </items>
* <event xmlns='http://jabber.org/protocol/pubsub#event'>
* </event>
* <items node='storage:bookmarks'>
* </message>
* <item id='current'>
*/
* <storage xmlns='storage:bookmarks'>
var
stanza
=
$msg
({
* <conference name='The Play's the Thing'
'
from
'
:
'
dummy@localhost
'
,
* autojoin='true'
'
to
'
:
'
dummy@localhost/resource
'
,
* jid='theplay@conference.shakespeare.lit'>
'
type
'
:
'
headline
'
,
* <nick>JC</nick>
'
id
'
:
'
rnfoo1
'
* </conference>
}).
c
(
'
event
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/pubsub#event
'
})
* </storage>
.
c
(
'
items
'
,
{
'
node
'
:
'
storage:bookmarks
'
})
* </item>
.
c
(
'
item
'
,
{
'
id
'
:
'
current
'
})
* </items>
.
c
(
'
storage
'
,
{
'
xmlns
'
:
'
storage:bookmarks
'
})
* </event>
.
c
(
'
conference
'
,
{
'
name
'
:
'
The Play's the Thing
'
,
* </message>
'
autojoin
'
:
'
true
'
,
*/
'
jid
'
:
'
theplay@conference.shakespeare.lit
'
})
.
c
(
'
nick
'
).
t
(
'
JC
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
_converse
.
bookmarks
.
length
).
toBe
(
1
);
expect
(
_converse
.
chatboxviews
.
get
(
'
theplay@conference.shakespeare.lit
'
)).
not
.
toBeUndefined
();
done
();
});
}));
}));
it
(
"
can be retrieved from the XMPP server
"
,
mock
.
initConverseWithPromises
(
it
(
"
can be retrieved from the XMPP server
"
,
mock
.
initConverseWithPromises
(
...
...
src/converse-bookmarks.js
View file @
fbef370b
...
@@ -155,7 +155,7 @@
...
@@ -155,7 +155,7 @@
_
.
each
(
body
.
querySelectorAll
(
'
.chatroom-form-container
'
),
u
.
removeElement
);
_
.
each
(
body
.
querySelectorAll
(
'
.chatroom-form-container
'
),
u
.
removeElement
);
body
.
insertAdjacentHTML
(
body
.
insertAdjacentHTML
(
'
beforeend
'
,
'
beforeend
'
,
tpl_chatroom_bookmark_form
({
tpl_chatroom_bookmark_form
({
heading
:
__
(
'
Bookmark this room
'
),
heading
:
__
(
'
Bookmark this room
'
),
label_name
:
__
(
'
The name for this bookmark:
'
),
label_name
:
__
(
'
The name for this bookmark:
'
),
...
@@ -222,7 +222,7 @@
...
@@ -222,7 +222,7 @@
// configuration settings.
// configuration settings.
_converse
.
api
.
settings
.
update
({
_converse
.
api
.
settings
.
update
({
allow_bookmarks
:
true
,
allow_bookmarks
:
true
,
hide_open_bookmarks
:
true
hide_open_bookmarks
:
true
});
});
// Promises exposed by this plugin
// Promises exposed by this plugin
_converse
.
api
.
promises
.
add
(
'
bookmarksInitialized
'
);
_converse
.
api
.
promises
.
add
(
'
bookmarksInitialized
'
);
...
@@ -370,10 +370,13 @@
...
@@ -370,10 +370,13 @@
}
}
},
},
onBookmarksReceived
(
deferred
,
iq
)
{
createBookmarksFromStanza
(
stanza
)
{
const
bookmarks
=
sizzle
(
const
bookmarks
=
sizzle
(
'
items[node="storage:bookmarks"] item[id="current"] storage conference
'
,
'
items[node="storage:bookmarks"]
'
+
iq
'
item#current
'
+
'
storage[xmlns="storage:bookmarks"]
'
+
'
conference
'
,
stanza
)
)
_
.
forEach
(
bookmarks
,
(
bookmark
)
=>
{
_
.
forEach
(
bookmarks
,
(
bookmark
)
=>
{
this
.
create
({
this
.
create
({
...
@@ -383,6 +386,10 @@
...
@@ -383,6 +386,10 @@
'
nick
'
:
bookmark
.
querySelector
(
'
nick
'
).
textContent
'
nick
'
:
bookmark
.
querySelector
(
'
nick
'
).
textContent
});
});
});
});
},
onBookmarksReceived
(
deferred
,
iq
)
{
this
.
createBookmarksFromStanza
(
iq
);
if
(
!
_
.
isUndefined
(
deferred
))
{
if
(
!
_
.
isUndefined
(
deferred
))
{
return
deferred
.
resolve
();
return
deferred
.
resolve
();
}
}
...
@@ -557,6 +564,16 @@
...
@@ -557,6 +564,16 @@
]).
then
(
initBookmarks
)
]).
then
(
initBookmarks
)
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
_converse
.
on
(
'
connected
'
,
()
=>
{
// Add a handler for bookmarks pushed from other connected clients
// (from the same user obviously)
_converse
.
connection
.
addHandler
((
message
)
=>
{
if
(
message
.
querySelector
(
'
event[xmlns="
'
+
Strophe
.
NS
.
PUBSUB
+
'
#event"]
'
))
{
_converse
.
bookmarks
.
createBookmarksFromStanza
(
message
);
}
},
null
,
'
message
'
,
'
headline
'
,
null
,
_converse
.
bare_jid
);
});
const
afterReconnection
=
function
()
{
const
afterReconnection
=
function
()
{
if
(
!
_converse
.
allow_bookmarks
)
{
if
(
!
_converse
.
allow_bookmarks
)
{
return
;
return
;
...
...
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