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
b5c56c83
Commit
b5c56c83
authored
Sep 05, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `getFullname` to XMPPStatus model and use that
instead of returning the fullname as fallback in `getNickname`
parent
5f5de90f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
56 deletions
+31
-56
spec/muc.js
spec/muc.js
+5
-49
src/headless/converse-core.js
src/headless/converse-core.js
+5
-0
src/headless/converse-muc.js
src/headless/converse-muc.js
+1
-1
src/headless/converse-roster.js
src/headless/converse-roster.js
+2
-2
src/headless/converse-vcard.js
src/headless/converse-vcard.js
+11
-1
tests/utils.js
tests/utils.js
+7
-3
No files found.
spec/muc.js
View file @
b5c56c83
...
@@ -280,22 +280,10 @@
...
@@ -280,22 +280,10 @@
}
}
});
});
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
let
stanza
=
await
u
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
`iq[to="
${
muc_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
());
// We pretend this is a new room, so no disco info is returned.
/* <iq from="jordie.langen@chat.example.org/converse.js-11659299" to="myroom@conference.chat.example.org" type="get">
const
disco_selector
=
`iq[to="
${
muc_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
;
* <query xmlns="http://jabber.org/protocol/disco#info"/>
const
stanza
=
await
u
.
waitUntil
(()
=>
IQ_stanzas
.
filter
(
iq
=>
iq
.
querySelector
(
disco_selector
)).
pop
());
* </iq>
// We pretend this is a new room, so no disco info is returned.
* <iq xmlns="jabber:client" type="error" to="jordie.langen@chat.example.org/converse.js-11659299" from="myroom@conference.chat.example.org">
* <error type="cancel">
* <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
* </error>
* </iq>
*/
const
features_stanza
=
$iq
({
const
features_stanza
=
$iq
({
'
from
'
:
'
lounge@montague.lit
'
,
'
from
'
:
'
lounge@montague.lit
'
,
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
...
@@ -307,40 +295,8 @@
...
@@ -307,40 +295,8 @@
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@montague.lit
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@montague.lit
'
);
spyOn
(
view
.
model
,
'
join
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
join
'
).
and
.
callThrough
();
await
test_utils
.
waitForReservedNick
(
_converse
,
muc_jid
,
''
);
/* <iq to="myroom@conference.chat.example.org"
const
input
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
input[name="nick"]
'
),
1000
);
* from="jordie.langen@chat.example.org/converse.js-11659299"
* type="get">
* <query xmlns="http://jabber.org/protocol/disco#info"
* node="x-roomuser-item"/>
* </iq>
*/
stanza
=
await
u
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
s
=>
sizzle
(
`iq[to="
${
muc_jid
}
"] query[node="x-roomuser-item"]`
,
s
).
length
).
pop
()
);
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="romeo@montague.lit/orchard" id="
${
stanza
.
getAttribute
(
"
id
"
)}
" to="lounge@montague.lit" `
+
`type="get" xmlns="jabber:client">`
+
`<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
/* <iq xmlns="jabber:client" type="error" to="jordie.langen@chat.example.org/converse.js-11659299" from="myroom@conference.chat.example.org">
* <error type="cancel">
* <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
* </error>
* </iq>
*/
const
result_stanza
=
$iq
({
'
type
'
:
'
error
'
,
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
'
to
'
:
_converse
.
connection
.
jid
}).
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
.
c
(
'
item-not-found
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result_stanza
));
const
input
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
input[name="nick"]
'
));
expect
(
view
.
model
.
get
(
'
connection_status
'
)).
toBe
(
converse
.
ROOMSTATUS
.
NICKNAME_REQUIRED
);
expect
(
view
.
model
.
get
(
'
connection_status
'
)).
toBe
(
converse
.
ROOMSTATUS
.
NICKNAME_REQUIRED
);
input
.
value
=
'
nicky
'
;
input
.
value
=
'
nicky
'
;
view
.
el
.
querySelector
(
'
input[type=submit]
'
).
click
();
view
.
el
.
querySelector
(
'
input[type=submit]
'
).
click
();
...
...
src/headless/converse-core.js
View file @
b5c56c83
...
@@ -1292,6 +1292,11 @@ _converse.initialize = async function (settings, callback) {
...
@@ -1292,6 +1292,11 @@ _converse.initialize = async function (settings, callback) {
return
_converse
.
nickname
;
return
_converse
.
nickname
;
},
},
getFullname
()
{
// Gets overridden in converse-vcard
return
''
;
},
constructPresence
(
type
,
status_message
)
{
constructPresence
(
type
,
status_message
)
{
let
presence
;
let
presence
;
type
=
_
.
isString
(
type
)
?
type
:
(
this
.
get
(
'
status
'
)
||
_converse
.
default_state
);
type
=
_
.
isString
(
type
)
?
type
:
(
this
.
get
(
'
status
'
)
||
_converse
.
default_state
);
...
...
src/headless/converse-muc.js
View file @
b5c56c83
...
@@ -1201,7 +1201,7 @@ converse.plugins.add('converse-muc', {
...
@@ -1201,7 +1201,7 @@ converse.plugins.add('converse-muc', {
'
xmlns
'
:
Strophe
.
NS
.
DISCO_INFO
,
'
xmlns
'
:
Strophe
.
NS
.
DISCO_INFO
,
'
node
'
:
'
x-roomuser-item
'
'
node
'
:
'
x-roomuser-item
'
})
})
const
result
=
await
_converse
.
api
.
sendIQ
(
stanza
,
null
,
tru
e
);
const
result
=
await
_converse
.
api
.
sendIQ
(
stanza
,
null
,
fals
e
);
if
(
u
.
isErrorObject
(
result
))
{
if
(
u
.
isErrorObject
(
result
))
{
throw
result
;
throw
result
;
}
}
...
...
src/headless/converse-roster.js
View file @
b5c56c83
...
@@ -294,7 +294,7 @@ converse.plugins.add('converse-roster', {
...
@@ -294,7 +294,7 @@ converse.plugins.add('converse-roster', {
if
(
message
&&
message
!==
""
)
{
if
(
message
&&
message
!==
""
)
{
pres
.
c
(
"
status
"
).
t
(
message
).
up
();
pres
.
c
(
"
status
"
).
t
(
message
).
up
();
}
}
const
nick
=
_converse
.
xmppstatus
.
getNickname
();
const
nick
=
_converse
.
xmppstatus
.
getNickname
()
||
_converse
.
xmppstatus
.
getFullname
()
;
if
(
nick
)
{
if
(
nick
)
{
pres
.
c
(
'
nick
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
NICK
}).
t
(
nick
).
up
();
pres
.
c
(
'
nick
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
NICK
}).
t
(
nick
).
up
();
}
}
...
@@ -473,7 +473,7 @@ converse.plugins.add('converse-roster', {
...
@@ -473,7 +473,7 @@ converse.plugins.add('converse-roster', {
if
(
item
.
getAttribute
(
'
action
'
)
===
'
add
'
)
{
if
(
item
.
getAttribute
(
'
action
'
)
===
'
add
'
)
{
_converse
.
roster
.
addAndSubscribe
(
_converse
.
roster
.
addAndSubscribe
(
item
.
getAttribute
(
'
jid
'
),
item
.
getAttribute
(
'
jid
'
),
_converse
.
xmppstatus
.
getNickname
()
_converse
.
xmppstatus
.
getNickname
()
||
_converse
.
xmppstatus
.
getFullname
()
);
);
}
}
});
});
...
...
src/headless/converse-vcard.js
View file @
b5c56c83
...
@@ -24,10 +24,20 @@ converse.plugins.add('converse-vcard', {
...
@@ -24,10 +24,20 @@ converse.plugins.add('converse-vcard', {
const
{
_converse
}
=
this
.
__super__
;
const
{
_converse
}
=
this
.
__super__
;
const
nick
=
this
.
__super__
.
getNickname
.
apply
(
this
);
const
nick
=
this
.
__super__
.
getNickname
.
apply
(
this
);
if
(
!
nick
&&
_converse
.
xmppstatus
.
vcard
)
{
if
(
!
nick
&&
_converse
.
xmppstatus
.
vcard
)
{
return
_converse
.
xmppstatus
.
vcard
.
get
(
'
nickname
'
)
||
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
)
;
return
_converse
.
xmppstatus
.
vcard
.
get
(
'
nickname
'
);
}
else
{
}
else
{
return
nick
;
return
nick
;
}
}
},
getFullname
(){
const
{
_converse
}
=
this
.
__super__
;
const
fullname
=
this
.
__super__
.
getFullname
.
apply
(
this
);
if
(
!
fullname
&&
_converse
.
xmppstatus
.
vcard
)
{
return
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
);
}
else
{
return
fullname
;
}
}
}
},
},
...
...
tests/utils.js
View file @
b5c56c83
...
@@ -205,10 +205,14 @@
...
@@ -205,10 +205,14 @@
'
id
'
:
IQ_id
,
'
id
'
:
IQ_id
,
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
'
to
'
:
_converse
.
connection
.
jid
'
to
'
:
_converse
.
connection
.
jid
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
,
'
node
'
:
'
x-roomuser-item
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
,
'
node
'
:
'
x-roomuser-item
'
});
.
c
(
'
identity
'
,
{
'
category
'
:
'
conference
'
,
'
name
'
:
nick
,
'
type
'
:
'
text
'
});
if
(
nick
)
{
stanza
.
c
(
'
identity
'
,
{
'
category
'
:
'
conference
'
,
'
name
'
:
nick
,
'
type
'
:
'
text
'
});
}
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
stanza
));
return
u
.
waitUntil
(()
=>
view
.
model
.
get
(
'
nick
'
));
if
(
nick
)
{
return
u
.
waitUntil
(()
=>
view
.
model
.
get
(
'
nick
'
));
}
};
};
...
...
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