1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

take reactions into account when fetching relations from e2e rooms

This commit is contained in:
Bruno Windels
2019-06-27 14:06:57 +02:00
parent 44c7844a4b
commit c5cddf1607

View File

@@ -1886,6 +1886,21 @@ function _encryptEventIfNeeded(client, event, room) {
return client._crypto.encryptEvent(event, room); return client._crypto.encryptEvent(event, room);
} }
/**
* Returns the eventType that should be used taking encryption into account
* for a given eventType.
* @param {MatrixClient} client the client
* @param {string} roomId the room for the events `eventType` relates to
* @param {string} eventType the event type
* @return {string} the event type taking encryption into account
*/
function _getEncryptedIfNeededEventType(client, roomId, eventType) {
if (eventType === "m.reaction") {
return eventType;
}
const isEncrypted = client.isRoomEncrypted(roomId);
return isEncrypted ? "m.room.encrypted" : eventType;
}
function _updatePendingEventStatus(room, event, newStatus) { function _updatePendingEventStatus(room, event, newStatus) {
if (room) { if (room) {
@@ -3994,7 +4009,7 @@ MatrixClient.prototype.getCanResetTimelineCallback = function() {
MatrixClient.prototype.relations = MatrixClient.prototype.relations =
async function(roomId, eventId, relationType, eventType, opts = {}) { async function(roomId, eventId, relationType, eventType, opts = {}) {
const isEncrypted = this.isRoomEncrypted(roomId); const isEncrypted = this.isRoomEncrypted(roomId);
const fetchedEventType = isEncrypted ? "m.room.encrypted" : eventType; const fetchedEventType = _getEncryptedIfNeededEventType(this, roomId, eventType);
const result = await this.fetchRelations( const result = await this.fetchRelations(
roomId, roomId,