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
62ef18a0
Commit
62ef18a0
authored
Feb 20, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
muc_fetch_members now accepts an array of affiliations
parent
590a8862
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
16 deletions
+43
-16
CHANGES.md
CHANGES.md
+1
-0
docs/source/configuration.rst
docs/source/configuration.rst
+3
-2
spec/muc.js
spec/muc.js
+25
-4
src/headless/converse-muc.js
src/headless/converse-muc.js
+7
-7
tests/utils.js
tests/utils.js
+7
-3
No files found.
CHANGES.md
View file @
62ef18a0
...
...
@@ -3,6 +3,7 @@
## 7.0.0 (Unreleased)
-
[
muc_fetch_members
](
https://conversejs.org/docs/html/configuration.html#muc-fetch-members
)
now also accepts an array of affiliations to fetch.
-
Replace Backbone with
[
Skeletor
](
https://github.com/skeletorjs/skeletor
)
-
Start using
[
lit-html
](
https://lit-html.polymer-project.org/
)
instead of lodash for templating.
-
Bugfix. Handle stanza that clears the MUC subject
...
...
docs/source/configuration.rst
View file @
62ef18a0
...
...
@@ -1079,6 +1079,8 @@ muc_fetch_members
* Default: ``true``
* Possible values: Array containing any of the following: ``['member', 'admin', 'owner']``
Determines whether Converse.js will fetch the member lists for a MUC
(multi-user chat) when the user first enters it.
...
...
@@ -1091,8 +1093,7 @@ The member lists consists of three lists of users who have the affiliations
``member``, ``admin`` and ``owner`` respectively.
By fetching member lists, Converse.js will always show these users as
participants of the MUC, which makes it behave a bit more like modern chat
apps.
participants of the MUC, giving them a permanent "presence" in the MUC.
muc_history_max_stanzas
...
...
spec/muc.js
View file @
62ef18a0
...
...
@@ -362,12 +362,11 @@
[
'
rosterGroupsFetched
'
],
{
'
muc_fetch_members
'
:
true
},
async
function
(
done
,
_converse
)
{
cons
t
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
le
t
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
const
muc_jid
=
'
lounge@montague.lit
'
;
spyOn
(
_converse
.
ChatRoomOccupants
.
prototype
,
'
fetchMembers
'
).
and
.
callThrough
();
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
muc_jid
,
'
romeo
'
);
let
view
=
_converse
.
chatboxviews
.
get
(
muc_jid
);
expect
(
view
.
model
.
occupants
.
fetchMembers
).
toHaveBeenCalled
(
);
expect
(
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
'
query item[affiliation]
'
)).
length
).
toBe
(
3
);
// Check in reverse order that we requested all three lists
const
owner_iq
=
sent_IQs
.
pop
();
...
...
@@ -387,11 +386,33 @@
`<iq id="
${
member_iq
.
getAttribute
(
'
id
'
)}
" to="
${
muc_jid
}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin"><item affiliation="member"/></query>`
+
`</iq>`
);
view
.
close
();
_converse
.
connection
.
IQ_stanzas
=
[];
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
_converse
.
muc_fetch_members
=
false
;
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
orchard@montague.lit
'
,
'
romeo
'
);
view
=
_converse
.
chatboxviews
.
get
(
'
orchard@montague.lit
'
);
expect
(
view
.
model
.
occupants
.
fetchMembers
.
calls
.
count
()).
toBe
(
1
);
expect
(
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
'
query item[affiliation]
'
)).
length
).
toBe
(
0
);
await
view
.
close
();
_converse
.
connection
.
IQ_stanzas
=
[];
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
_converse
.
muc_fetch_members
=
[
'
admin
'
];
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
courtyard@montague.lit
'
,
'
romeo
'
);
view
=
_converse
.
chatboxviews
.
get
(
'
courtyard@montague.lit
'
);
expect
(
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
'
query item[affiliation]
'
)).
length
).
toBe
(
1
);
expect
(
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
'
query item[affiliation="admin"]
'
)).
length
).
toBe
(
1
);
view
.
close
();
_converse
.
connection
.
IQ_stanzas
=
[];
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
_converse
.
muc_fetch_members
=
[
'
owner
'
];
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
garden@montague.lit
'
,
'
romeo
'
);
view
=
_converse
.
chatboxviews
.
get
(
'
garden@montague.lit
'
);
expect
(
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
'
query item[affiliation]
'
)).
length
).
toBe
(
1
);
expect
(
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
'
query item[affiliation="owner"]
'
)).
length
).
toBe
(
1
);
view
.
close
();
done
();
}));
...
...
src/headless/converse-muc.js
View file @
62ef18a0
...
...
@@ -460,9 +460,7 @@ converse.plugins.add('converse-muc', {
async
onConnectionStatusChanged
()
{
if
(
this
.
session
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
)
{
if
(
_converse
.
muc_fetch_members
)
{
await
this
.
occupants
.
fetchMembers
();
}
await
this
.
occupants
.
fetchMembers
();
await
this
.
fetchMessages
();
await
this
.
clearMessageQueue
();
/**
...
...
@@ -1339,9 +1337,7 @@ converse.plugins.add('converse-muc', {
const
aff_lists
=
await
Promise
.
all
(
all_affiliations
.
map
(
a
=>
this
.
getAffiliationList
(
a
)));
const
old_members
=
aff_lists
.
reduce
((
acc
,
val
)
=>
(
u
.
isErrorObject
(
val
)
?
acc
:
[...
val
,
...
acc
]),
[]);
await
this
.
setAffiliations
(
muc_utils
.
computeAffiliationsDelta
(
true
,
false
,
members
,
old_members
));
if
(
_converse
.
muc_fetch_members
)
{
return
this
.
occupants
.
fetchMembers
();
}
await
this
.
occupants
.
fetchMembers
();
},
/**
...
...
@@ -2228,7 +2224,11 @@ converse.plugins.add('converse-muc', {
},
async
fetchMembers
()
{
const
all_affiliations
=
[
'
member
'
,
'
admin
'
,
'
owner
'
];
const
affs
=
_converse
.
muc_fetch_members
;
const
all_affiliations
=
Array
.
isArray
(
affs
)
?
affs
:
(
affs
?
[
'
member
'
,
'
admin
'
,
'
owner
'
]
:
[]);
if
(
affs
.
length
===
0
)
{
return
;
}
const
aff_lists
=
await
Promise
.
all
(
all_affiliations
.
map
(
a
=>
this
.
chatroom
.
getAffiliationList
(
a
)));
const
new_members
=
aff_lists
.
reduce
((
acc
,
val
)
=>
(
u
.
isErrorObject
(
val
)
?
acc
:
[...
val
,
...
acc
]),
[]);
const
known_affiliations
=
all_affiliations
.
filter
(
a
=>
!
u
.
isErrorObject
(
aff_lists
[
all_affiliations
.
indexOf
(
a
)]));
...
...
tests/utils.js
View file @
62ef18a0
...
...
@@ -204,6 +204,9 @@
utils
.
returnMemberLists
=
async
function
(
_converse
,
muc_jid
,
members
=
[],
affiliations
=
[
'
member
'
,
'
owner
'
,
'
admin
'
])
{
if
(
affiliations
.
length
===
0
)
{
return
;
}
const
stanzas
=
_converse
.
connection
.
IQ_stanzas
;
if
(
affiliations
.
includes
(
'
member
'
))
{
...
...
@@ -302,9 +305,10 @@
await
room_creation_promise
;
const
view
=
_converse
.
chatboxviews
.
get
(
muc_jid
);
await
u
.
waitUntil
(()
=>
(
view
.
model
.
session
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
));
if
(
_converse
.
muc_fetch_members
)
{
await
utils
.
returnMemberLists
(
_converse
,
muc_jid
,
members
);
}
const
affs
=
_converse
.
muc_fetch_members
;
const
all_affiliations
=
Array
.
isArray
(
affs
)
?
affs
:
(
affs
?
[
'
member
'
,
'
admin
'
,
'
owner
'
]
:
[]);
await
utils
.
returnMemberLists
(
_converse
,
muc_jid
,
members
,
all_affiliations
);
await
view
.
model
.
messages
.
fetched
;
};
...
...
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