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
ba099969
Commit
ba099969
authored
Feb 08, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't allow PEP bookmarks if #publish-options is not advertised
parent
fbef370b
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
577 additions
and
546 deletions
+577
-546
spec/bookmarks.js
spec/bookmarks.js
+305
-260
spec/chatbox.js
spec/chatbox.js
+4
-4
spec/chatroom.js
spec/chatroom.js
+234
-248
spec/protocol.js
spec/protocol.js
+1
-1
src/converse-bookmarks.js
src/converse-bookmarks.js
+22
-21
tests/mock.js
tests/mock.js
+0
-7
tests/utils.js
tests/utils.js
+11
-5
No files found.
spec/bookmarks.js
View file @
ba099969
This diff is collapsed.
Click to expand it.
spec/chatbox.js
View file @
ba099969
...
...
@@ -57,7 +57,7 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
waitUntil
FeatureSupportConfirmed
(
_converse
,
'
localhost
'
,
'
vcard-temp
'
)
test_utils
.
waitUntil
DiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
]
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
...
...
@@ -1228,7 +1228,7 @@
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntil
FeatureSupportConfirmed
(
_converse
,
'
localhost
'
,
'
vcard-temp
'
)
test_utils
.
waitUntil
DiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
]
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
...
...
@@ -1842,7 +1842,7 @@
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntil
FeatureSupportConfirmed
(
_converse
,
'
localhost
'
,
'
vcard-temp
'
)
test_utils
.
waitUntil
DiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
]
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
...
...
@@ -1989,7 +1989,7 @@
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntil
FeatureSupportConfirmed
(
_converse
,
'
localhost
'
,
'
vcard-temp
'
)
test_utils
.
waitUntil
DiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
]
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
...
...
spec/chatroom.js
View file @
ba099969
This diff is collapsed.
Click to expand it.
spec/protocol.js
View file @
ba099969
...
...
@@ -55,7 +55,7 @@
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntil
FeatureSupportConfirmed
(
_converse
,
'
localhost
'
,
'
vcard-temp
'
)
test_utils
.
waitUntil
DiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
]
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
...
...
src/converse-bookmarks.js
View file @
ba099969
...
...
@@ -71,32 +71,28 @@
this
.
setBookmarkState
();
},
render
Heading
()
{
render
BookmarkToggle
()
{
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
;
const
bookmark_button
=
tpl_chatroom_bookmark_toggle
(
_
.
assignIn
(
this
.
model
.
toJSON
(),
{
info_toggle_bookmark
:
__
(
'
Bookmark this room
'
),
bookmarked
:
this
.
model
.
get
(
'
bookmarked
'
)
}));
const
close_button
=
this
.
el
.
querySelector
(
'
.close-chatbox-button
'
);
close_button
.
insertAdjacentHTML
(
'
afterend
'
,
bookmark_button
);
},
renderHeading
()
{
this
.
__super__
.
renderHeading
.
apply
(
this
,
arguments
);
const
{
_converse
}
=
this
.
__super__
;
if
(
_converse
.
allow_bookmarks
)
{
_converse
.
api
.
disco
.
getIdentity
(
'
pubsub
'
,
'
pep
'
,
_converse
.
bare_jid
).
then
((
identity
)
=>
{
if
(
_
.
isNil
(
identity
))
{
return
;
}
const
div
=
document
.
createElement
(
'
div
'
);
div
.
innerHTML
=
this
.
generateHeadingHTML
();
const
bookmark_button
=
tpl_chatroom_bookmark_toggle
(
_
.
assignIn
(
this
.
model
.
toJSON
(),
{
info_toggle_bookmark
:
__
(
'
Bookmark this room
'
),
bookmarked
:
this
.
model
.
get
(
'
bookmarked
'
)
}
));
const
close_button
=
div
.
querySelector
(
'
.close-chatbox-button
'
);
close_button
.
insertAdjacentHTML
(
'
afterend
'
,
bookmark_button
);
this
.
el
.
querySelector
(
'
.chat-head-chatroom
'
).
innerHTML
=
div
.
innerHTML
;
});
}
else
{
return
this
.
__super__
.
renderHeading
.
apply
(
this
,
arguments
);
this
.
renderBookmarkToggle
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}
},
...
...
@@ -537,9 +533,14 @@
if
(
!
_converse
.
allow_bookmarks
)
{
return
;
}
// Only initialize bookmarks if the server supports PEP
_converse
.
api
.
disco
.
getIdentity
(
'
pubsub
'
,
'
pep
'
,
_converse
.
bare_jid
).
then
((
identity
)
=>
{
if
(
_
.
isNil
(
identity
))
{
Promise
.
all
([
_converse
.
api
.
disco
.
getIdentity
(
'
pubsub
'
,
'
pep
'
,
_converse
.
bare_jid
),
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
PUBSUB
+
'
#publish-options
'
,
_converse
.
bare_jid
)
]).
then
((
args
)
=>
{
const
identity
=
args
[
0
],
options_support
=
args
[
1
];
if
(
_
.
isNil
(
identity
)
||
!
options_support
.
supported
)
{
_converse
.
emit
(
'
bookmarksInitialized
'
);
return
;
}
...
...
tests/mock.js
View file @
ba099969
...
...
@@ -119,13 +119,6 @@
},
settings
||
{}));
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
var
entity
=
_converse
.
api
.
disco
.
entities
.
get
(
_converse
.
bare_jid
,
true
);
entity
.
identities
.
create
({
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
});
entity
.
waitUntilFeaturesDiscovered
.
resolve
();
window
.
converse_disable_effects
=
true
;
return
_converse
;
}
...
...
tests/utils.js
View file @
ba099969
...
...
@@ -14,7 +14,7 @@
}
utils
.
waitUntil
=
waitUntilPromise
.
default
;
utils
.
waitUntil
FeatureSupportConfirmed
=
function
(
_converse
,
entity_jid
,
feature_name
)
{
utils
.
waitUntil
DiscoConfirmed
=
function
(
_converse
,
entity_jid
,
identities
,
features
)
{
var
IQ_disco
,
stanza
;
return
utils
.
waitUntil
(
function
()
{
IQ_disco
=
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
function
(
iq
)
{
...
...
@@ -24,13 +24,19 @@
return
!
_
.
isUndefined
(
IQ_disco
);
},
300
).
then
(
function
()
{
var
info_IQ_id
=
IQ_disco
.
nodeTree
.
getAttribute
(
'
id
'
);
stanza
=
$iq
({
var
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
from
'
:
'
localhost
'
,
'
from
'
:
entity_jid
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
info_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
feature
'
,
{
'
var
'
:
feature_name
});
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
});
_
.
forEach
(
identities
,
function
(
identity
)
{
stanza
.
c
(
'
identity
'
,
{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}).
up
()
});
_
.
forEach
(
features
,
function
(
feature
)
{
stanza
.
c
(
'
feature
'
,
{
'
var
'
:
feature
}).
up
();
});
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
stanza
));
});
}
...
...
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