Fix delete rights
This commit is contained in:
parent
c7a21360ee
commit
d1b8461b54
@ -17,7 +17,7 @@ export default class PopupDeleteMessages {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let title: string, description: string, buttons: PopupButton[];
|
let title: string, description: string, buttons: PopupButton[];
|
||||||
title = `Delete Message${mids.length == 1 ? '' : 's'}?`;
|
title = `Delete ${mids.length == 1 ? '' : mids.length + ' '}Message${mids.length == 1 ? '' : 's'}?`;
|
||||||
description = `Are you sure you want to delete ${mids.length == 1 ? 'this message' : 'these messages'}?`;
|
description = `Are you sure you want to delete ${mids.length == 1 ? 'this message' : 'these messages'}?`;
|
||||||
|
|
||||||
if(peerID == $rootScope.myID) {
|
if(peerID == $rootScope.myID) {
|
||||||
@ -39,12 +39,45 @@ export default class PopupDeleteMessages {
|
|||||||
isDanger: true,
|
isDanger: true,
|
||||||
callback: () => callback(true)
|
callback: () => callback(true)
|
||||||
});
|
});
|
||||||
} else if(appChatsManager.hasRights(-peerID, 'deleteRevoke')) {
|
} else {
|
||||||
buttons.push({
|
const chat = appChatsManager.getChat(-peerID);
|
||||||
text: 'DELETE FOR ALL',
|
|
||||||
isDanger: true,
|
const hasRights = appChatsManager.hasRights(-peerID, 'deleteRevoke');
|
||||||
callback: () => callback(true)
|
if(chat._ == 'chat') {
|
||||||
});
|
const canRevoke = hasRights ? mids.slice() : mids.filter(mid => {
|
||||||
|
const message = appMessagesManager.getMessage(mid);
|
||||||
|
return message.fromID == $rootScope.myID;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(canRevoke.length) {
|
||||||
|
if(canRevoke.length == mids.length) {
|
||||||
|
buttons.push({
|
||||||
|
text: 'DELETE FOR ALL',
|
||||||
|
isDanger: true,
|
||||||
|
callback: () => callback(true)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const buttonText = 'Unsend my and delete';
|
||||||
|
buttons.push({
|
||||||
|
text: buttonText,
|
||||||
|
isDanger: true,
|
||||||
|
callback: () => callback(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
description = `You can also delete the ${canRevoke.length} message${canRevoke.length > 1 ? 's' : ''} you sent from the inboxes of other group members by pressing "${buttonText}".`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!hasRights || appChatsManager.isBroadcast(-peerID)) {
|
||||||
|
buttons.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons.push({
|
||||||
|
text: 'DELETE FOR ALL',
|
||||||
|
isDanger: true,
|
||||||
|
callback: () => callback(true)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2392,11 +2392,12 @@ export class AppMessagesManager {
|
|||||||
|
|
||||||
public canDeleteMessage(messageID: number) {
|
public canDeleteMessage(messageID: number) {
|
||||||
const message = this.messagesStorage[messageID];
|
const message = this.messagesStorage[messageID];
|
||||||
if(message) {
|
return message && (
|
||||||
return message.peerID > 0 || message.fromID == $rootScope.myID || appChatsManager.hasRights(message.peerID, 'deleteRevoke');
|
message.peerID > 0
|
||||||
} else {
|
|| message.fromID == $rootScope.myID
|
||||||
return false;
|
|| appChatsManager.getChat(message.peerID)._ == 'chat'
|
||||||
}
|
|| appChatsManager.hasRights(message.peerID, 'deleteRevoke')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public applyConversations(dialogsResult: MessagesPeerDialogs.messagesPeerDialogs) {
|
public applyConversations(dialogsResult: MessagesPeerDialogs.messagesPeerDialogs) {
|
||||||
|
@ -557,8 +557,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
avatar-element {
|
avatar-element {
|
||||||
height: 32px;
|
height: 2rem;
|
||||||
width: 32px;
|
width: 2rem;
|
||||||
font-size: .875rem;
|
font-size: .875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,5 +48,6 @@
|
|||||||
.peer-avatar {
|
.peer-avatar {
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
width: 2rem;
|
width: 2rem;
|
||||||
|
font-size: .875rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user