Don't allow pin or edit of messages with a send status (#31158)
* Don't allow pin or edit of messages with a send status * lint and improve comments.
This commit is contained in:
@@ -70,7 +70,9 @@ export function canEditContent(matrixClient: MatrixClient, mxEvent: MatrixEvent)
|
||||
|
||||
if (
|
||||
!isCancellable ||
|
||||
mxEvent.status === EventStatus.CANCELLED ||
|
||||
// Editing local echos is not supported(results in send a message that references the local ID).
|
||||
// We need to ensure the event is not local, and therefore has no send status.
|
||||
mxEvent.status !== null ||
|
||||
mxEvent.isRedacted() ||
|
||||
mxEvent.isRelation(RelationType.Replace) ||
|
||||
mxEvent.getSender() !== matrixClient.getUserId()
|
||||
|
||||
@@ -81,6 +81,9 @@ export default class PinningUtils {
|
||||
const room = matrixClient.getRoom(mxEvent.getRoomId());
|
||||
if (!room) return false;
|
||||
|
||||
// Should have a non-local event id
|
||||
if (mxEvent.status !== null) return false;
|
||||
|
||||
return PinningUtils.userHasPinOrUnpinPermission(matrixClient, room) && PinningUtils.isPinnable(mxEvent);
|
||||
}
|
||||
|
||||
@@ -94,6 +97,9 @@ export default class PinningUtils {
|
||||
const room = matrixClient.getRoom(mxEvent.getRoomId());
|
||||
if (!room) return false;
|
||||
|
||||
// Should have a non-local event id
|
||||
if (mxEvent.status !== null) return false;
|
||||
|
||||
return PinningUtils.userHasPinOrUnpinPermission(matrixClient, room) && PinningUtils.isUnpinnable(mxEvent);
|
||||
}
|
||||
|
||||
@@ -123,6 +129,9 @@ export default class PinningUtils {
|
||||
const eventId = mxEvent.getId();
|
||||
if (!eventId) return;
|
||||
|
||||
// Should have a non-local event id
|
||||
if (mxEvent.status !== null) return;
|
||||
|
||||
// Get the current pinned events of the room
|
||||
const pinnedIds: Array<string> =
|
||||
room
|
||||
|
||||
Reference in New Issue
Block a user