allow closed group updates from non-admin user

pull/1357/head
Audric Ackermann 5 years ago
parent 90bd30d0ac
commit e5db9916a5
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -270,7 +270,6 @@
}; };
}; };
const getGroupSettingsProps = () => { const getGroupSettingsProps = () => {
const ourPK = window.textsecure.storage.user.getNumber();
const members = this.model.get('members') || []; const members = this.model.get('members') || [];
return { return {
@ -281,7 +280,7 @@
avatarPath: this.model.getAvatarPath(), avatarPath: this.model.getAvatarPath(),
isGroup: !this.model.isPrivate(), isGroup: !this.model.isPrivate(),
isPublic: this.model.isPublic(), isPublic: this.model.isPublic(),
isAdmin: this.model.get('groupAdmins').includes(ourPK), isAdmin: true, // allow closed group edits from anyone this.model.get('groupAdmins').includes(ourPK),
isRss: this.model.isRss(), isRss: this.model.isRss(),
memberCount: members.length, memberCount: members.length,
amMod: this.model.isModerator( amMod: this.model.isModerator(

@ -21,9 +21,8 @@
this.members = groupConvo.get('members') || []; this.members = groupConvo.get('members') || [];
this.avatarPath = groupConvo.getAvatarPath(); this.avatarPath = groupConvo.getAvatarPath();
const ourPK = textsecure.storage.user.getNumber(); // any member can update a closed group name
this.isAdmin = true;
this.isAdmin = groupConvo.get('groupAdmins').includes(ourPK);
// public chat settings overrides // public chat settings overrides
if (this.isPublic) { if (this.isPublic) {
@ -79,7 +78,6 @@
Whisper.UpdateGroupMembersDialogView = Whisper.View.extend({ Whisper.UpdateGroupMembersDialogView = Whisper.View.extend({
className: 'loki-dialog modal', className: 'loki-dialog modal',
initialize(groupConvo) { initialize(groupConvo) {
const ourPK = textsecure.storage.user.getNumber();
this.groupName = groupConvo.get('name'); this.groupName = groupConvo.get('name');
this.close = this.close.bind(this); this.close = this.close.bind(this);
this.onSubmit = this.onSubmit.bind(this); this.onSubmit = this.onSubmit.bind(this);
@ -99,7 +97,8 @@
this.existingMembers = []; this.existingMembers = [];
} else { } else {
this.titleText = i18n('updateGroupDialogTitle', this.groupName); this.titleText = i18n('updateGroupDialogTitle', this.groupName);
this.isAdmin = groupConvo.get('groupAdmins').includes(ourPK); // anybody can edit a closed group name or members
this.isAdmin = true;
const convos = window.getConversations().models.filter(d => !!d); const convos = window.getConversations().models.filter(d => !!d);
this.existingMembers = groupConvo.get('members') || []; this.existingMembers = groupConvo.get('members') || [];

@ -245,7 +245,7 @@ class SessionGroupSettings extends React.Component<Props, any> {
const showUpdateGroupNameButton = const showUpdateGroupNameButton =
isPublic && !isKickedFromGroup isPublic && !isKickedFromGroup
? amMod && !isBlocked ? amMod && !isBlocked
: isAdmin && !isBlocked; : isAdmin && !isBlocked && !isKickedFromGroup;
const showUpdateGroupMembersButton = const showUpdateGroupMembersButton =
!isPublic && !isKickedFromGroup && !isBlocked && isAdmin; !isPublic && !isKickedFromGroup && !isBlocked && isAdmin;

@ -85,9 +85,8 @@ export async function preprocessGroupMessage(
if (newGroup) { if (newGroup) {
conversation.updateGroupAdmins(group.admins); conversation.updateGroupAdmins(group.admins);
} else { } else {
// be sure to drop a message from a non admin if it tries to change group members // group members and names can be changed from any member
// or change the group name const fromAdmin = true;
const fromAdmin = conversation.get('groupAdmins').includes(primarySource);
if (!fromAdmin) { if (!fromAdmin) {
// Make sure the message is not removing members / renaming the group // Make sure the message is not removing members / renaming the group

Loading…
Cancel
Save