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
8bd968a0
Commit
8bd968a0
authored
May 08, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also use the VCard cache for the user's own status
parent
708b1dbe
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
71 additions
and
71 deletions
+71
-71
spec/chatbox.js
spec/chatbox.js
+3
-5
spec/chatroom.js
spec/chatroom.js
+1
-3
spec/messages.js
spec/messages.js
+1
-1
spec/protocol.js
spec/protocol.js
+1
-1
spec/register.js
spec/register.js
+16
-18
spec/spoilers.js
spec/spoilers.js
+2
-2
src/converse-core.js
src/converse-core.js
+5
-4
src/converse-profile.js
src/converse-profile.js
+25
-17
src/converse-roster.js
src/converse-roster.js
+2
-2
src/converse-vcard.js
src/converse-vcard.js
+0
-9
tests/mock.js
tests/mock.js
+7
-5
tests/utils.js
tests/utils.js
+8
-4
No files found.
spec/chatbox.js
View file @
8bd968a0
...
...
@@ -58,7 +58,7 @@
var
view
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
])
.
then
(()
=>
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
get
(
'
fullname
'
)),
300
)
.
then
(()
=>
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
)),
300
)
.
then
(
function
()
{
test_utils
.
openControlBox
();
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
...
...
@@ -753,7 +753,7 @@
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
])
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
return
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
...
...
@@ -783,7 +783,6 @@
// Check that the message was received and check the message parameters
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
var
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
_converse
.
xmppstatus
.
get
(
'
fullname
'
));
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
me
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
...
...
@@ -902,7 +901,7 @@
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
])
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
return
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
...
...
@@ -932,7 +931,6 @@
// Check that the message was received and check the message parameters
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
var
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
_converse
.
xmppstatus
.
get
(
'
fullname
'
));
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
me
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
...
...
spec/chatroom.js
View file @
8bd968a0
...
...
@@ -851,9 +851,7 @@
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
])
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
return
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
))
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
return
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
...
spec/messages.js
View file @
8bd968a0
...
...
@@ -1137,7 +1137,7 @@
var
msg_object
=
chatbox
.
messages
.
models
[
0
];
var
msg_author
=
view
.
el
.
querySelector
(
'
.chat-content .chat-msg:last-child .chat-msg-author
'
);
expect
(
msg_author
.
textContent
).
toBe
(
'
dummy@localhost
'
);
expect
(
msg_author
.
textContent
).
toBe
(
'
Max Mustermann
'
);
var
msg_time
=
view
.
el
.
querySelector
(
'
.chat-content .chat-msg:last-child .chat-msg-time
'
);
var
time
=
moment
(
msg_object
.
get
(
'
time
'
)).
format
(
_converse
.
time_format
);
...
...
spec/protocol.js
View file @
8bd968a0
...
...
@@ -59,7 +59,7 @@
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhost
'
,
[],
[
'
vcard-temp
'
])
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
return
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
/* The process by which a user subscribes to a contact, including
...
...
spec/register.js
View file @
8bd968a0
...
...
@@ -33,25 +33,23 @@
allow_registration
:
true
},
function
(
done
,
_converse
)
{
test_utils
.
waitUntil
(
function
()
{
return
_
.
get
(
_converse
.
chatboxviews
.
get
(
'
controlbox
'
),
'
registerpanel
'
);
},
300
)
test_utils
.
waitUntil
(()
=>
_
.
get
(
_converse
.
chatboxviews
.
get
(
'
controlbox
'
),
'
registerpanel
'
),
300
)
.
then
(
function
()
{
var
cbview
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
test_utils
.
openControlBox
();
var
$panels
=
$
(
cbview
.
el
.
querySelector
(
'
.controlbox-panes
'
));
var
$login
=
$panels
.
children
().
first
();
var
$registration
=
$panels
.
children
().
last
();
var
register_link
=
cbview
.
el
.
querySelector
(
'
a.register-account
'
);
expect
(
register_link
.
textContent
).
toBe
(
"
Create an account
"
);
register_link
.
click
();
test_utils
.
waitUntil
(
function
()
{
return
$registration
.
is
(
'
:visible
'
);
},
300
).
then
(
function
()
{
expect
(
$login
.
is
(
'
:visible
'
)).
toBe
(
false
);
done
();
});
var
cbview
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
test_utils
.
openControlBox
();
var
$panels
=
$
(
cbview
.
el
.
querySelector
(
'
.controlbox-panes
'
));
var
$login
=
$panels
.
children
().
first
();
var
$registration
=
$panels
.
children
().
last
();
var
register_link
=
cbview
.
el
.
querySelector
(
'
a.register-account
'
);
expect
(
register_link
.
textContent
).
toBe
(
"
Create an account
"
);
register_link
.
click
();
test_utils
.
waitUntil
(
function
()
{
return
$registration
.
is
(
'
:visible
'
);
},
300
).
then
(
function
()
{
expect
(
$login
.
is
(
'
:visible
'
)).
toBe
(
false
);
done
();
});
});
}));
...
...
spec/spoilers.js
View file @
8bd968a0
...
...
@@ -155,7 +155,7 @@
expect
(
body_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
/* Test the HTML spoiler message */
expect
(
view
.
el
.
querySelector
(
'
.chat-msg-author
'
).
textContent
).
toBe
(
'
dummy@localhost
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg-author
'
).
textContent
).
toBe
(
'
Max Mustermann
'
);
var
spoiler_msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg-text.spoiler
'
);
expect
(
spoiler_msg_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
...
...
@@ -234,7 +234,7 @@
expect
(
body_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
/* Test the HTML spoiler message */
expect
(
view
.
el
.
querySelector
(
'
.chat-msg-author
'
).
textContent
).
toBe
(
'
dummy@localhost
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg-author
'
).
textContent
).
toBe
(
'
Max Mustermann
'
);
var
spoiler_msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg-text.spoiler
'
);
expect
(
spoiler_msg_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
...
...
src/converse-core.js
View file @
8bd968a0
...
...
@@ -836,15 +836,16 @@
defaults
()
{
return
{
"
jid
"
:
_converse
.
bare_jid
,
"
nickname
"
:
_converse
.
nickname
,
"
status
"
:
_converse
.
default_state
,
"
vcard_updated
"
:
null
,
'
image
'
:
_converse
.
DEFAULT_IMAGE
,
'
image_type
'
:
_converse
.
DEFAULT_IMAGE_TYPE
}
},
initialize
()
{
this
.
vcard
=
_converse
.
vcards
.
findWhere
({
'
jid
'
:
this
.
get
(
'
jid
'
)});
if
(
_
.
isNil
(
this
.
vcard
))
{
this
.
vcard
=
_converse
.
vcards
.
create
({
'
jid
'
:
this
.
get
(
'
jid
'
)});
}
this
.
on
(
'
change:status
'
,
(
item
)
=>
{
const
status
=
this
.
get
(
'
status
'
);
this
.
sendPresence
(
status
);
...
...
src/converse-profile.js
View file @
8bd968a0
...
...
@@ -57,7 +57,9 @@
},
toHTML
()
{
return
tpl_profile_modal
(
_
.
extend
(
this
.
model
.
toJSON
(),
{
return
tpl_profile_modal
(
_
.
extend
(
this
.
model
.
toJSON
(),
this
.
model
.
vcard
.
toJSON
(),
{
'
heading_profile
'
:
__
(
'
Your Profile
'
),
'
label_close
'
:
__
(
'
Close
'
),
'
label_email
'
:
__
(
'
Email
'
),
...
...
@@ -88,7 +90,7 @@
setVCard
(
body
,
data
)
{
_converse
.
api
.
vcard
.
set
(
data
)
.
then
(()
=>
{
_converse
.
api
.
vcard
.
update
(
this
.
model
,
true
);
_converse
.
api
.
vcard
.
update
(
this
.
model
.
vcard
,
true
);
const
html
=
tpl_alert
({
'
message
'
:
__
(
'
Profile data succesfully saved
'
),
...
...
@@ -145,19 +147,22 @@
},
toHTML
()
{
return
tpl_chat_status_modal
(
_
.
extend
(
this
.
model
.
toJSON
(),
{
'
label_away
'
:
__
(
'
Away
'
),
'
label_close
'
:
__
(
'
Close
'
),
'
label_busy
'
:
__
(
'
Busy
'
),
'
label_cancel
'
:
__
(
'
Cancel
'
),
'
label_custom_status
'
:
__
(
'
Custom status
'
),
'
label_offline
'
:
__
(
'
Offline
'
),
'
label_online
'
:
__
(
'
Online
'
),
'
label_save
'
:
__
(
'
Save
'
),
'
label_xa
'
:
__
(
'
Away for long
'
),
'
modal_title
'
:
__
(
'
Change chat status
'
),
'
placeholder_status_message
'
:
__
(
'
Personal status message
'
)
}));
return
tpl_chat_status_modal
(
_
.
extend
(
this
.
model
.
toJSON
(),
this
.
model
.
vcard
.
toJSON
(),
{
'
label_away
'
:
__
(
'
Away
'
),
'
label_close
'
:
__
(
'
Close
'
),
'
label_busy
'
:
__
(
'
Busy
'
),
'
label_cancel
'
:
__
(
'
Cancel
'
),
'
label_custom_status
'
:
__
(
'
Custom status
'
),
'
label_offline
'
:
__
(
'
Offline
'
),
'
label_online
'
:
__
(
'
Online
'
),
'
label_save
'
:
__
(
'
Save
'
),
'
label_xa
'
:
__
(
'
Away for long
'
),
'
modal_title
'
:
__
(
'
Change chat status
'
),
'
placeholder_status_message
'
:
__
(
'
Personal status message
'
)
}));
},
afterRender
()
{
...
...
@@ -196,12 +201,15 @@
initialize
()
{
this
.
model
.
on
(
"
change
"
,
this
.
render
,
this
);
this
.
model
.
vcard
.
on
(
"
change
"
,
this
.
render
,
this
);
},
toHTML
()
{
const
chat_status
=
this
.
model
.
get
(
'
status
'
)
||
'
offline
'
;
return
tpl_profile_view
(
_
.
extend
(
this
.
model
.
toJSON
(),
{
'
fullname
'
:
this
.
model
.
get
(
'
fullname
'
)
||
_converse
.
bare_jid
,
return
tpl_profile_view
(
_
.
extend
(
this
.
model
.
toJSON
(),
this
.
model
.
vcard
.
toJSON
(),
{
'
fullname
'
:
this
.
model
.
vcard
.
get
(
'
fullname
'
)
||
_converse
.
bare_jid
,
'
status_message
'
:
this
.
model
.
get
(
'
status_message
'
)
||
__
(
"
I am %1$s
"
,
this
.
getPrettyStatus
(
chat_status
)),
'
chat_status
'
:
chat_status
,
...
...
src/converse-roster.js
View file @
8bd968a0
...
...
@@ -159,7 +159,7 @@
if
(
message
&&
message
!==
""
)
{
pres
.
c
(
"
status
"
).
t
(
message
).
up
();
}
const
nick
=
_converse
.
xmppstatus
.
get
(
'
nickname
'
)
||
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
const
nick
=
_converse
.
xmppstatus
.
vcard
.
get
(
'
nickname
'
)
||
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
);
if
(
nick
)
{
pres
.
c
(
'
nick
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
NICK
}).
t
(
nick
).
up
();
}
...
...
@@ -388,7 +388,7 @@
if
(
item
.
getAttribute
(
'
action
'
)
===
'
add
'
)
{
_converse
.
roster
.
addAndSubscribe
(
item
.
getAttribute
(
'
jid
'
),
_converse
.
xmppstatus
.
get
(
'
nickname
'
)
||
_converse
.
xmppstatus
.
get
(
'
fullname
'
)
_converse
.
xmppstatus
.
vcard
.
get
(
'
nickname
'
)
||
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
)
);
}
});
...
...
src/converse-vcard.js
View file @
8bd968a0
...
...
@@ -111,15 +111,6 @@
_converse
.
api
.
disco
.
addFeature
(
Strophe
.
NS
.
VCARD
);
});
_converse
.
on
(
'
statusInitialized
'
,
function
fetchOwnVCard
()
{
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
VCARD
,
_converse
.
domain
)
.
then
((
result
)
=>
{
if
(
result
.
length
)
{
_converse
.
api
.
vcard
.
update
(
_converse
.
xmppstatus
);
}})
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
});
_
.
extend
(
_converse
.
api
,
{
'
vcard
'
:
{
'
set
'
:
setVCard
,
...
...
tests/mock.js
View file @
8bd968a0
...
...
@@ -94,14 +94,11 @@
'
animate
'
:
false
,
'
use_emojione
'
:
false
,
'
no_trimming
'
:
true
,
'
auto_login
'
:
true
,
'
jid
'
:
'
dummy@localhost
'
,
'
view_mode
'
:
mock
.
view_mode
,
'
password
'
:
'
secret
'
,
'
debug
'
:
false
},
settings
||
{}));
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
api
.
vcard
.
get
=
function
(
model
,
force
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
jid
;
...
...
@@ -132,7 +129,12 @@
resolve
(
result
);
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
};
if
(
_
.
get
(
settings
,
'
auto_login
'
)
!==
false
)
{
_converse
.
api
.
user
.
login
({
'
jid
'
:
'
dummy@localhost
'
,
'
password
'
:
'
secret
'
});
}
window
.
converse_disable_effects
=
true
;
return
_converse
;
}
...
...
tests/utils.js
View file @
8bd968a0
...
...
@@ -144,12 +144,16 @@
utils
.
waitUntil
(()
=>
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
node
)
=>
node
.
nodeTree
.
querySelector
(
'
query
'
).
getAttribute
(
'
node
'
)
===
'
x-roomuser-item
'
).
length
_converse
.
connection
.
IQ_stanzas
,
(
node
)
=>
{
const
query
=
node
.
nodeTree
.
querySelector
(
'
query
'
);
return
query
&&
query
.
getAttribute
(
'
node
'
)
===
'
x-roomuser-item
'
}).
length
}).
then
(
function
()
{
const
last_stanza
=
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
node
)
=>
node
.
nodeTree
.
querySelector
(
'
query
'
).
getAttribute
(
'
node
'
)
===
'
x-roomuser-item
'
).
pop
().
nodeTree
;
_converse
.
connection
.
IQ_stanzas
,
(
node
)
=>
{
const
query
=
node
.
nodeTree
.
querySelector
(
'
query
'
);
return
query
&&
query
.
getAttribute
(
'
node
'
)
===
'
x-roomuser-item
'
}).
pop
().
nodeTree
;
// The XMPP server returns the reserved nick for this user.
const
IQ_id
=
last_stanza
.
getAttribute
(
'
id
'
);
...
...
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