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
014354d0
Commit
014354d0
authored
Sep 07, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #986 Affiliation changes aren't displayed in the chat
parent
47bde925
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
50 deletions
+194
-50
CHANGES.md
CHANGES.md
+1
-0
dist/converse.js
dist/converse.js
+42
-8
spec/chatroom.js
spec/chatroom.js
+113
-33
src/converse-muc-views.js
src/converse-muc-views.js
+38
-9
No files found.
CHANGES.md
View file @
014354d0
...
...
@@ -10,6 +10,7 @@
-
#421 XEP-0308: Last Message Correction
-
#497 XEP-0384: OMEMO encrypted messaging
-
#968 Use nickname from VCard when joining a room
-
#986 Affiliation changes aren't displayed in the chat
-
#1081 Allow for shift-enter to insert newlines
-
#1091 There's now only one CSS file for all view modes.
-
#1094 Show room members who aren't currently online
...
...
dist/converse.js
View file @
014354d0
...
...
@@ -68264,6 +68264,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.occupants.on('add', this.showJoinNotification, this);
this.model.occupants.on('remove', this.showLeaveNotification, this);
this.model.occupants.on('change:show', this.showJoinOrLeaveNotification, this);
this.model.occupants.on('change:role', this.informOfOccupantsRoleChange, this);
this.model.occupants.on('change:affiliation', this.informOfOccupantsAffiliationChange, this);
this.createEmojiPicker();
this.createOccupantsView();
this.render().insertIntoDOM();
...
...
@@ -68382,10 +68384,34 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.occupantsview = new _converse.ChatRoomOccupantsView({
'model': this.model.occupants
});
this.occupantsview.model.on('change:role', this.informOfOccupantsRoleChange, this);
return this;
},
informOfOccupantsAffiliationChange(occupant, changed) {
const previous_affiliation = occupant._previousAttributes.affiliation,
current_affiliation = occupant.get('affiliation');
if (previous_affiliation === 'admin') {
this.showChatEvent(__("%1$s is no longer an admin of this groupchat", occupant.get('nick')));
} else if (previous_affiliation === 'owner') {
this.showChatEvent(__("%1$s is no longer an owner of this groupchat", occupant.get('nick')));
} else if (previous_affiliation === 'outcast') {
this.showChatEvent(__("%1$s is no longer banned from this groupchat", occupant.get('nick')));
}
if (current_affiliation === 'none' && previous_affiliation === 'member') {
this.showChatEvent(__("%1$s is no longer a permanent member of this groupchat", occupant.get('nick')));
}
if (current_affiliation === 'member') {
this.showChatEvent(__("%1$s is now a permanent member of this groupchat", occupant.get('nick')));
} else if (current_affiliation === 'outcast') {
this.showChatEvent(__("%1$s has been banned from this groupchat", occupant.get('nick')));
} else if (current_affiliation === 'admin' || current_affiliation == 'owner') {
this.showChatEvent(__(`%1$s is now an ${current_affiliation} of this groupchat`, occupant.get('nick')));
}
},
informOfOccupantsRoleChange(occupant, changed) {
const previous_role = occupant._previousAttributes.role;
...
...
@@ -68605,12 +68631,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
/* Check that a command to change a groupchat user's role or
* affiliation has anough arguments.
*/
// TODO check if first argument is valid
if (args.length < 1 || args.length > 2) {
this.showErrorMessage(__('Error: the "%1$s" command takes two arguments, the user\'s nickname and optionally a reason.', command));
return false;
}
if (!this.model.occupants.findWhere({
'nick': args[0]
}) && !this.model.occupants.findWhere({
'jid': args[0]
})) {
this.showErrorMessage(__('Error: couldn\'t find a groupchat participant "%1$s"', args[0]));
return false;
}
return true;
},
...
...
@@ -68692,13 +68726,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const occupant = this.model.occupants.findWhere({
'nick': args[0]
}) || this.model.occupants.findWhere({
'jid': args[0]
});
if (!occupant) {
this.showErrorMessage(__(`Error: Can't find a groupchat participant with the nickname "${args[0]}"`));
break;
}
this.model.setAffiliation('member', [{
'jid': occupant.get('jid'),
'reason': args[1]
...
...
@@ -69275,6 +69305,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
},
showLeaveNotification(occupant) {
if (_.includes(occupant.get('states'), '303') || _.includes(occupant.get('states'), '307')) {
return;
}
const nick = occupant.get('nick'),
stat = occupant.get('status'),
last_el = this.content.lastElementChild;
spec/chatroom.js
View file @
014354d0
This diff is collapsed.
Click to expand it.
src/converse-muc-views.js
View file @
014354d0
...
...
@@ -542,6 +542,8 @@
this
.
model
.
occupants
.
on
(
'
add
'
,
this
.
showJoinNotification
,
this
);
this
.
model
.
occupants
.
on
(
'
remove
'
,
this
.
showLeaveNotification
,
this
);
this
.
model
.
occupants
.
on
(
'
change:show
'
,
this
.
showJoinOrLeaveNotification
,
this
);
this
.
model
.
occupants
.
on
(
'
change:role
'
,
this
.
informOfOccupantsRoleChange
,
this
);
this
.
model
.
occupants
.
on
(
'
change:affiliation
'
,
this
.
informOfOccupantsAffiliationChange
,
this
);
this
.
createEmojiPicker
();
this
.
createOccupantsView
();
...
...
@@ -643,10 +645,32 @@
*/
this
.
model
.
occupants
.
chatroomview
=
this
;
this
.
occupantsview
=
new
_converse
.
ChatRoomOccupantsView
({
'
model
'
:
this
.
model
.
occupants
});
this
.
occupantsview
.
model
.
on
(
'
change:role
'
,
this
.
informOfOccupantsRoleChange
,
this
);
return
this
;
},
informOfOccupantsAffiliationChange
(
occupant
,
changed
)
{
const
previous_affiliation
=
occupant
.
_previousAttributes
.
affiliation
,
current_affiliation
=
occupant
.
get
(
'
affiliation
'
);
if
(
previous_affiliation
===
'
admin
'
)
{
this
.
showChatEvent
(
__
(
"
%1$s is no longer an admin of this groupchat
"
,
occupant
.
get
(
'
nick
'
)))
}
else
if
(
previous_affiliation
===
'
owner
'
)
{
this
.
showChatEvent
(
__
(
"
%1$s is no longer an owner of this groupchat
"
,
occupant
.
get
(
'
nick
'
)))
}
else
if
(
previous_affiliation
===
'
outcast
'
)
{
this
.
showChatEvent
(
__
(
"
%1$s is no longer banned from this groupchat
"
,
occupant
.
get
(
'
nick
'
)))
}
if
(
current_affiliation
===
'
none
'
&&
previous_affiliation
===
'
member
'
)
{
this
.
showChatEvent
(
__
(
"
%1$s is no longer a permanent member of this groupchat
"
,
occupant
.
get
(
'
nick
'
)))
}
if
(
current_affiliation
===
'
member
'
)
{
this
.
showChatEvent
(
__
(
"
%1$s is now a permanent member of this groupchat
"
,
occupant
.
get
(
'
nick
'
)))
}
else
if
(
current_affiliation
===
'
outcast
'
)
{
this
.
showChatEvent
(
__
(
"
%1$s has been banned from this groupchat
"
,
occupant
.
get
(
'
nick
'
)))
}
else
if
(
current_affiliation
===
'
admin
'
||
current_affiliation
==
'
owner
'
)
{
this
.
showChatEvent
(
__
(
`%1$s is now an
${
current_affiliation
}
of this groupchat`
,
occupant
.
get
(
'
nick
'
)))
}
},
informOfOccupantsRoleChange
(
occupant
,
changed
)
{
const
previous_role
=
occupant
.
_previousAttributes
.
role
;
if
(
previous_role
===
'
moderator
'
)
{
...
...
@@ -831,13 +855,16 @@
/* Check that a command to change a groupchat user's role or
* affiliation has anough arguments.
*/
// TODO check if first argument is valid
if
(
args
.
length
<
1
||
args
.
length
>
2
)
{
this
.
showErrorMessage
(
__
(
'
Error: the "%1$s" command takes two arguments, the user
\'
s nickname and optionally a reason.
'
,
command
)
);
return
false
;
}
if
(
!
this
.
model
.
occupants
.
findWhere
({
'
nick
'
:
args
[
0
]})
&&
!
this
.
model
.
occupants
.
findWhere
({
'
jid
'
:
args
[
0
]}))
{
this
.
showErrorMessage
(
__
(
'
Error: couldn
\'
t find a groupchat participant "%1$s"
'
,
args
[
0
]));
return
false
;
}
return
true
;
},
...
...
@@ -873,6 +900,7 @@
if
(
!
this
.
verifyAffiliations
([
'
owner
'
,
'
admin
'
])
||
!
this
.
validateRoleChangeCommand
(
command
,
args
))
{
break
;
}
this
.
model
.
setAffiliation
(
'
outcast
'
,
[{
'
jid
'
:
args
[
0
],
'
reason
'
:
args
[
1
]
...
...
@@ -929,11 +957,9 @@
if
(
!
this
.
verifyAffiliations
([
'
admin
'
,
'
owner
'
])
||
!
this
.
validateRoleChangeCommand
(
command
,
args
))
{
break
;
}
const
occupant
=
this
.
model
.
occupants
.
findWhere
({
'
nick
'
:
args
[
0
]});
if
(
!
occupant
)
{
this
.
showErrorMessage
(
__
(
`Error: Can't find a groupchat participant with the nickname "
${
args
[
0
]}
"`
));
break
;
}
const
occupant
=
this
.
model
.
occupants
.
findWhere
({
'
nick
'
:
args
[
0
]})
||
this
.
model
.
occupants
.
findWhere
({
'
jid
'
:
args
[
0
]});
this
.
model
.
setAffiliation
(
'
member
'
,
[{
'
jid
'
:
occupant
.
get
(
'
jid
'
),
'
reason
'
:
args
[
1
]
...
...
@@ -1485,6 +1511,9 @@
},
showLeaveNotification
(
occupant
)
{
if
(
_
.
includes
(
occupant
.
get
(
'
states
'
),
'
303
'
)
||
_
.
includes
(
occupant
.
get
(
'
states
'
),
'
307
'
))
{
return
;
}
const
nick
=
occupant
.
get
(
'
nick
'
),
stat
=
occupant
.
get
(
'
status
'
),
last_el
=
this
.
content
.
lastElementChild
;
...
...
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