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
99c06876
Commit
99c06876
authored
Oct 13, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #537 Open xmpp: URIs inside Converse
parent
2c441279
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
8 deletions
+67
-8
dist/converse.js
dist/converse.js
+19
-5
spec/chatroom.js
spec/chatroom.js
+32
-0
src/converse-muc-views.js
src/converse-muc-views.js
+7
-1
src/converse-muc.js
src/converse-muc.js
+3
-0
src/templates/chatroom_head.html
src/templates/chatroom_head.html
+1
-1
src/utils/core.js
src/utils/core.js
+5
-1
No files found.
dist/converse.js
View file @
99c06876
...
...
@@ -68945,11 +68945,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'click .chatbox-navback': 'showControlBox',
'click .close-chatbox-button': 'close',
'click .configure-chatroom-button': 'getAndRenderConfigurationForm',
'click .show-room-details-modal': 'showRoomDetailsModal',
'click .hide-occupants': 'hideOccupants',
'click .new-msgs-indicator': 'viewUnreadMessages',
'click .occupant-nick': 'onOccupantClicked',
'click a.open-chatroom': 'openChatRoomFromURIClicked',
'click .send-button': 'onFormSubmitted',
'click .show-room-details-modal': 'showRoomDetailsModal',
'click .toggle-call': 'toggleCall',
'click .toggle-occupants': 'toggleOccupants',
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
...
...
@@ -69284,6 +69285,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.insertIntoTextArea(ev.target.textContent);
},
openChatRoomFromURIClicked(ev) {
ev.preventDefault();
_converse.api.rooms.open(ev.target.href);
},
handleChatStateNotification(message) {
/* Override the method on the ChatBoxView base class to
* ignore <gone/> notifications in groupchats.
...
...
@@ -72164,6 +72171,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
};
const createChatRoom = function createChatRoom(jid, attrs) {
if (jid.startsWith('xmpp:') && jid.endsWith('?join')) {
jid = jid.replace(/^xmpp:/, '').replace(/\?join$/, '');
}
return getChatRoom(jid, attrs, true);
};
...
...
@@ -79418,9 +79429,7 @@ __e( o.Strophe.getNodeFromJid(o.jid) ) +
__e( o.Strophe.getDomainFromJid(o.jid) ) +
'\n ';
} ;
__p += '\n </div>\n <!-- Sanitized in converse-muc-views. We want to render links. -->\n <p class="chatroom-description" title="' +
__e(o.description) +
'">' +
__p += '\n </div>\n <!-- Sanitized in converse-muc-views. We want to render links. -->\n <p class="chatroom-description">' +
((__t = (o.description)) == null ? '' : __t) +
'</p>\n</div>\n<div class="chatbox-buttons row no-gutters">\n <a class="chatbox-btn close-chatbox-button fa fa-sign-out-alt" title="' +
__e(o.info_close) +
...
...
@@ -82057,6 +82066,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.addHyperlinks = function (text) {
return URI.withinString(text, url => {
let classes = '';
const uri = new URI(url);
url = uri.normalize()._string;
const pretty_url = uri._parts.urn ? url : uri.readable();
...
...
@@ -82065,7 +82075,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
url = 'http://' + url;
}
return `<a target="_blank" rel="noopener" href="${url}">${u.escapeHTML(pretty_url)}</a>`;
if (uri._parts.protocol === 'xmpp' && uri._parts.query === 'join') {
classes += 'open-chatroom';
}
return `<a target="_blank" rel="noopener" class="${classes}" href="${url}">${u.escapeHTML(pretty_url)}</a>`;
}, {
'start': /\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi
});
spec/chatroom.js
View file @
99c06876
...
...
@@ -411,6 +411,38 @@
describe
(
"
A Groupchat
"
,
function
()
{
it
(
"
is opened when an xmpp: URI is clicked inside another groupchat
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
let
view
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
waitUntil
(()
=>
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
))
.
then
(()
=>
{
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
2
);
const
message
=
'
Please go to xmpp:coven@chat.shakespeare.lit?join
'
,
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
'
from
'
:
'
lounge@localhost/
'
+
nick
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
to
'
:
'
dummy@localhost
'
,
'
type
'
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
view
.
model
.
onMessage
(
msg
);
view
.
el
.
querySelector
(
'
.chat-msg__text a
'
).
click
();
return
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
===
3
)
}).
then
(()
=>
{
expect
(
_
.
includes
(
_converse
.
chatboxes
.
pluck
(
'
id
'
),
'
coven@chat.shakespeare.lit
'
)).
toBe
(
true
);
done
()
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
it
(
"
shows a notification if its not anonymous
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
...
...
src/converse-muc-views.js
View file @
99c06876
...
...
@@ -509,11 +509,12 @@
'
click .chatbox-navback
'
:
'
showControlBox
'
,
'
click .close-chatbox-button
'
:
'
close
'
,
'
click .configure-chatroom-button
'
:
'
getAndRenderConfigurationForm
'
,
'
click .show-room-details-modal
'
:
'
showRoomDetailsModal
'
,
'
click .hide-occupants
'
:
'
hideOccupants
'
,
'
click .new-msgs-indicator
'
:
'
viewUnreadMessages
'
,
'
click .occupant-nick
'
:
'
onOccupantClicked
'
,
'
click a.open-chatroom
'
:
'
openChatRoomFromURIClicked
'
,
'
click .send-button
'
:
'
onFormSubmitted
'
,
'
click .show-room-details-modal
'
:
'
showRoomDetailsModal
'
,
'
click .toggle-call
'
:
'
toggleCall
'
,
'
click .toggle-occupants
'
:
'
toggleOccupants
'
,
'
click .toggle-smiley ul.emoji-picker li
'
:
'
insertEmoji
'
,
...
...
@@ -813,6 +814,11 @@
this
.
insertIntoTextArea
(
ev
.
target
.
textContent
);
},
openChatRoomFromURIClicked
(
ev
)
{
ev
.
preventDefault
();
_converse
.
api
.
rooms
.
open
(
ev
.
target
.
href
);
},
handleChatStateNotification
(
message
)
{
/* Override the method on the ChatBoxView base class to
* ignore <gone/> notifications in groupchats.
...
...
src/converse-muc.js
View file @
99c06876
...
...
@@ -1275,6 +1275,9 @@
};
const
createChatRoom
=
function
(
jid
,
attrs
)
{
if
(
jid
.
startsWith
(
'
xmpp:
'
)
&&
jid
.
endsWith
(
'
?join
'
))
{
jid
=
jid
.
replace
(
/^xmpp:/
,
''
).
replace
(
/
\?
join$/
,
''
);
}
return
getChatRoom
(
jid
,
attrs
,
true
);
};
...
...
src/templates/chatroom_head.html
View file @
99c06876
...
...
@@ -8,7 +8,7 @@
{[ } ]}
</div>
<!-- Sanitized in converse-muc-views. We want to render links. -->
<p
class=
"chatroom-description"
title=
"{{{o.description}}}"
>
{{o.description}}
</p>
<p
class=
"chatroom-description"
>
{{o.description}}
</p>
</div>
<div
class=
"chatbox-buttons row no-gutters"
>
<a
class=
"chatbox-btn close-chatbox-button fa fa-sign-out-alt"
title=
"{{{o.info_close}}}"
></a>
...
...
src/utils/core.js
View file @
99c06876
...
...
@@ -262,13 +262,17 @@
u
.
addHyperlinks
=
function
(
text
)
{
return
URI
.
withinString
(
text
,
url
=>
{
let
classes
=
''
;
const
uri
=
new
URI
(
url
);
url
=
uri
.
normalize
().
_string
;
const
pretty_url
=
uri
.
_parts
.
urn
?
url
:
uri
.
readable
();
if
(
!
uri
.
_parts
.
protocol
&&
!
url
.
startsWith
(
'
http://
'
)
&&
!
url
.
startsWith
(
'
https://
'
))
{
url
=
'
http://
'
+
url
;
}
return
`<a target="_blank" rel="noopener" href="
${
url
}
">
${
u
.
escapeHTML
(
pretty_url
)}
</a>`
;
if
(
uri
.
_parts
.
protocol
===
'
xmpp
'
&&
uri
.
_parts
.
query
===
'
join
'
)
{
classes
+=
'
open-chatroom
'
;
}
return
`<a target="_blank" rel="noopener" class="
${
classes
}
" href="
${
url
}
">
${
u
.
escapeHTML
(
pretty_url
)}
</a>`
;
},
{
'
start
'
:
/
\
b
(?:([
a
-
z
][
a
-
z0
-
9
.
+-
]
*
:
\
/
\
/
)
|
xmpp
:
|
mailto
:
|
www
\
.)
/
gi
});
...
...
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