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
376c50fb
Commit
376c50fb
authored
Dec 05, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When inviting to a members-only room, first add to user to the member-list
parent
088eb03b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
15 deletions
+118
-15
docs/CHANGES.md
docs/CHANGES.md
+2
-0
spec/chatroom.js
spec/chatroom.js
+81
-13
src/converse-core.js
src/converse-core.js
+1
-0
src/converse-muc.js
src/converse-muc.js
+34
-2
No files found.
docs/CHANGES.md
View file @
376c50fb
...
...
@@ -10,6 +10,8 @@
disconnection or reconnection events. [jcbrand]
-
Optimize fetching of MAM messages (in some cases happened on each page load). [jcbrand]
-
Fix empty controlbox toggle after disconnect. [jcbrand]
-
When inviting someone to a members-only room, first add them to the member
list. [jcbrand]
## 2.0.3 (2016-11-30)
-
#735 Room configuration button not visible. [jcbrand]
...
...
spec/chatroom.js
View file @
376c50fb
...
...
@@ -907,7 +907,7 @@
expect
(
$occupants
.
children
().
first
(
0
).
text
()).
toBe
(
"
newnick
"
);
}));
i
f
(
"
queries for the room information before attempting to join the user
"
,
mock
.
initConverse
(
function
(
converse
)
{
i
t
(
"
queries for the room information before attempting to join the user
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
sent_IQ
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
spyOn
(
converse
.
connection
,
'
sendIQ
'
).
andCallFake
(
function
(
iq
,
callback
,
errback
)
{
...
...
@@ -955,21 +955,21 @@
'
type
'
:
'
text
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
passwordprotected
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
hidden
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
temporary
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
open
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
unmoderated
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
nonanonymous
'
});
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_
passwordprotected
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_
hidden
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_
temporary
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_
open
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_
unmoderated
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_
nonanonymous
'
});
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
features_stanza
));
var
view
=
converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
expect
(
view
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
'
true
'
);
expect
(
view
.
model
.
get
(
'
hidden
'
)).
toBe
(
'
true
'
);
expect
(
view
.
model
.
get
(
'
temporary
'
)).
toBe
(
'
true
'
);
expect
(
view
.
model
.
get
(
'
open
'
)).
toBe
(
'
true
'
);
expect
(
view
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
'
true
'
);
expect
(
view
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
'
true
'
);
expect
(
view
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
hidden
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
temporary
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
open
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
true
);
}));
it
(
"
indicates when a room is no longer anonymous
"
,
mock
.
initConverse
(
function
(
converse
)
{
...
...
@@ -1398,5 +1398,73 @@
expect
(
view
.
$el
.
find
(
'
.chatroom-body p:last
'
).
text
()).
toBe
(
"
This room has reached its maximum number of occupants
"
);
}));
});
describe
(
"
Someone being invited to a chat room
"
,
function
()
{
it
(
"
will first be added to the member list if the chat room is members only
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
sent_IQ
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
spyOn
(
converse
.
connection
,
'
sendIQ
'
).
andCallFake
(
function
(
iq
,
callback
,
errback
)
{
sent_IQ
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
test_utils
.
openChatRoom
(
converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
dummy
'
);
// State that the chat is members-only via the features IQ
var
features_stanza
=
$iq
({
from
:
'
coven@chat.shakespeare.lit
'
,
'
id
'
:
IQ_id
,
'
to
'
:
'
dummy@localhost/desktop
'
,
'
type
'
:
'
result
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
'
category
'
:
'
conference
'
,
'
name
'
:
'
A Dark Cave
'
,
'
type
'
:
'
text
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_hidden
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_temporary
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_membersonly
'
}).
up
();
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
features_stanza
));
var
view
=
converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
expect
(
view
.
model
.
get
(
'
membersonly
'
)).
toBeTruthy
();
spyOn
(
view
,
'
setMemberList
'
).
andCallThrough
();
test_utils
.
createContacts
(
converse
,
'
current
'
);
var
sent_stanza
,
sent_id
;
spyOn
(
converse
.
connection
,
'
send
'
).
andCallFake
(
function
(
stanza
)
{
if
(
stanza
.
nodeTree
&&
stanza
.
nodeTree
.
nodeName
===
'
message
'
)
{
sent_id
=
stanza
.
nodeTree
.
getAttribute
(
'
id
'
);
sent_stanza
=
stanza
;
}
});
var
name
=
mock
.
cur_names
[
0
];
var
invitee_jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
reason
=
"
Please join this chat room
"
;
view
.
directInvite
(
invitee_jid
,
reason
);
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
"
<iq to='coven@chat.shakespeare.lit' type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<query xmlns='http://jabber.org/protocol/muc#admin'>
"
+
"
<item affiliation='member' jid='
"
+
invitee_jid
+
"
'/>
"
+
"
</query>
"
+
"
</iq>
"
);
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
// Strophe adds the xmlns attr (although not in spec)
"
<message from='dummy@localhost/resource' to='
"
+
invitee_jid
+
"
' id='
"
+
sent_id
+
"
' xmlns='jabber:client'>
"
+
"
<x xmlns='jabber:x:conference' jid='coven@chat.shakespeare.lit' reason='Please join this chat room'/>
"
+
"
</message>
"
);
}));
});
});
}));
src/converse-core.js
View file @
376c50fb
...
...
@@ -1182,6 +1182,7 @@
chat_status
=
$presence
.
find
(
'
show
'
).
text
()
||
'
online
'
,
status_message
=
$presence
.
find
(
'
status
'
),
contact
=
this
.
get
(
bare_jid
);
if
(
this
.
isSelf
(
bare_jid
))
{
if
((
converse
.
connection
.
jid
!==
jid
)
&&
(
presence_type
!==
'
unavailable
'
)
&&
...
...
src/converse-muc.js
View file @
376c50fb
...
...
@@ -494,6 +494,29 @@
this
.
insertIntoTextArea
(
ev
.
target
.
textContent
);
},
setMemberList
:
function
(
members
,
onSuccess
,
onError
)
{
/* Send an IQ stanza to the server to modify the
* member-list of this room.
*
* See: http://xmpp.org/extensions/xep-0045.html#modifymember
*
* Parameters:
* (Array) members: An array of member objects, containing
* the JID and affiliation of each.
* (Function) onSuccess: callback for a succesful response
* (Function) onError: callback for an error response
*/
var
iq
=
$iq
({
to
:
this
.
model
.
get
(
'
jid
'
),
type
:
"
set
"
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_ADMIN
});
_
.
each
(
members
,
function
(
member
)
{
iq
.
c
(
"
item
"
,
{
'
affiliation
'
:
member
.
affiliation
,
'
jid
'
:
member
.
jid
});
});
return
converse
.
connection
.
sendIQ
(
iq
,
onSuccess
,
onError
);
},
directInvite
:
function
(
recipient
,
reason
)
{
/* Send a direct invitation as per XEP-0249
*
...
...
@@ -501,6 +524,15 @@
* (String) recipient - JID of the person being invited
* (String) reason - Optional reason for the invitation
*/
if
(
this
.
model
.
get
(
'
membersonly
'
))
{
// When inviting to a members-only room, we first add
// the person to the member list, otherwise they won't
// be able to join.
this
.
setMemberList
([{
'
jid
'
:
recipient
,
'
affiliation
'
:
'
member
'
}]);
}
var
attrs
=
{
'
xmlns
'
:
'
jabber:x:conference
'
,
'
jid
'
:
this
.
model
.
get
(
'
jid
'
)
...
...
@@ -1082,7 +1114,7 @@
var
that
=
this
;
converse
.
connection
.
disco
.
info
(
this
.
model
.
get
(
'
jid
'
),
null
,
function
(
iq
)
{
/*
/*
* See http://xmpp.org/extensions/xep-0045.html#disco-roominfo
*
* <identity
...
...
@@ -1514,7 +1546,7 @@
this
.
model
.
save
(
'
connection_status
'
,
Strophe
.
Status
.
DISCONNECTED
);
this
.
showErrorMessage
(
pres
);
return
true
;
}
}
var
show_status_messages
=
true
;
var
is_self
=
pres
.
querySelector
(
"
status[code='110']
"
);
var
new_room
=
pres
.
querySelector
(
"
status[code='201']
"
);
...
...
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