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
9be43cce
Commit
9be43cce
authored
Jul 22, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't inform of role change which accompanies an affiliation change
given that it's implicit and can cause confusion
parent
bcbff1b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
9 deletions
+79
-9
spec/muc.js
spec/muc.js
+77
-8
src/converse-muc-views.js
src/converse-muc-views.js
+2
-1
No files found.
spec/muc.js
View file @
9be43cce
...
...
@@ -2758,6 +2758,75 @@
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
done
();
}));
it
(
"
informs users of role and affiliation changes
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
lounge@montague.lit
'
;
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
muc_jid
,
'
romeo
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
muc_jid
);
let
presence
=
$pres
({
'
from
'
:
'
lounge@montague.lit/annoyingGuy
'
,
'
id
'
:
'
27C55F89-1C6A-459A-9EB5-77690145D624
'
,
'
to
'
:
'
romeo@montague.lit/desktop
'
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
annoyingguy@montague.lit
'
,
'
affiliation
'
:
'
member
'
,
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
let
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has entered the groupchat
"
);
presence
=
$pres
({
'
from
'
:
'
lounge@montague.lit/annoyingGuy
'
,
'
to
'
:
'
romeo@montague.lit/desktop
'
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
annoyingguy@montague.lit
'
,
'
affiliation
'
:
'
member
'
,
'
role
'
:
'
visitor
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been muted
"
);
presence
=
$pres
({
'
from
'
:
'
lounge@montague.lit/annoyingGuy
'
,
'
to
'
:
'
romeo@montague.lit/desktop
'
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
annoyingguy@montague.lit
'
,
'
affiliation
'
:
'
member
'
,
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been given a voice
"
);
// Check that we don't see an info message concerning the role,
// if the affiliation has changed.
presence
=
$pres
({
'
from
'
:
'
lounge@montague.lit/annoyingGuy
'
,
'
to
'
:
'
romeo@montague.lit/desktop
'
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
annoyingguy@montague.lit
'
,
'
affiliation
'
:
'
none
'
,
'
role
'
:
'
visitor
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy is no longer a member of this groupchat
"
);
done
();
}));
});
...
...
@@ -3653,7 +3722,7 @@
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been given a voice
again
"
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been given a voice
"
);
done
();
}));
...
...
@@ -5129,7 +5198,7 @@
from='trollbox@montague.lit/troll'
to='romeo@montague.lit/orchard'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='
moderator
'
<item affiliation='
none
'
nick='troll'
role='visitor'/>
<status code='110'/>
...
...
@@ -5156,16 +5225,16 @@
// Check now that things get restored when the user is given a voice
let
info_msgs
=
sizzle
(
'
.chat-info
'
,
view
.
el
);
expect
(
info_msgs
.
length
).
toBe
(
4
);
expect
(
info_msgs
[
2
].
textContent
).
toBe
(
"
troll is no longer a moderator
"
);
expect
(
info_msgs
[
3
].
textContent
).
toBe
(
"
troll has been muted
"
);
expect
(
info_msgs
.
length
).
toBe
(
2
);
expect
(
info_msgs
[
0
].
textContent
).
toBe
(
"
troll has entered the groupchat
"
);
expect
(
info_msgs
[
1
].
textContent
).
toBe
(
"
troll is no longer an owner of this groupchat
"
);
stanza
=
u
.
toStanza
(
`
<presence
from='trollbox@montague.lit/troll'
to='romeo@montague.lit/orchard'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='
moderator
'
<item affiliation='
none
'
nick='troll'
role='participant'/>
<status code='110'/>
...
...
@@ -5180,8 +5249,8 @@
textarea
=
view
.
el
.
querySelector
(
'
.chat-textarea
'
);
expect
(
_
.
isNull
(
textarea
)).
toBe
(
false
);
expect
(
info_msgs
.
length
).
toBe
(
5
);
expect
(
info_msgs
[
4
].
textContent
).
toBe
(
"
troll has been given a voice again
"
);
expect
(
info_msgs
.
length
).
toBe
(
3
);
expect
(
info_msgs
[
2
].
textContent
).
toBe
(
"
troll has been given a voice
"
);
done
();
}));
});
...
...
src/converse-muc-views.js
View file @
9be43cce
...
...
@@ -648,7 +648,8 @@ converse.plugins.add('converse-muc-views', {
},
informOfOccupantsRoleChange
(
occupant
,
changed
)
{
if
(
changed
===
"
none
"
)
{
if
(
changed
===
"
none
"
||
occupant
.
changed
.
affiliation
)
{
// We don't inform of role changes if they accompany affiliation changes.
return
;
}
const
previous_role
=
occupant
.
_previousAttributes
.
role
;
...
...
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