Skip to content

Commit

Permalink
Exclude opt-in Element performance metrics from encryption
Browse files Browse the repository at this point in the history
This is needed for the system which is meant to be monitoring this metadata. See matrix-org/matrix-react-sdk#6766
  • Loading branch information
turt2live committed Sep 9, 2021
1 parent 341e936 commit 7911e63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/crypto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2757,12 +2757,22 @@ export class Crypto extends EventEmitter {
delete content['m.relates_to'];
}

// Treat element's performance metrics the same as `m.relates_to` (when present)
const elementPerfMetrics = content['io.element.performance_metrics'];
if (elementPerfMetrics) {
content = Object.assign({}, content);
delete content['io.element.performance_metrics'];
}

const encryptedContent = await alg.encryptMessage(
room, event.getType(), content);

if (mRelatesTo) {
encryptedContent['m.relates_to'] = mRelatesTo;
}
if (elementPerfMetrics) {
encryptedContent['io.element.performance_metrics'] = elementPerfMetrics;
}

event.makeEncrypted(
"m.room.encrypted",
Expand Down

0 comments on commit 7911e63

Please sign in to comment.