1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Expose the clear event content directly from an event

This commit is contained in:
Travis Ralston
2019-03-05 14:04:51 -07:00
parent 37f106d4af
commit 2f2deb5333
2 changed files with 13 additions and 8 deletions

View File

@@ -519,6 +519,17 @@ utils.extend(module.exports.MatrixEvent.prototype, {
decryptionResult.forwardingCurve25519KeyChain || [];
},
/**
* Gets the cleartext content for this event. If the event is not encrypted,
* or encryption has not been completed, this will return null.
*
* @returns {Object} The cleartext (decrypted) content for the event
*/
getClearContent: function() {
const ev = this._clearEvent;
return ev && ev.content ? ev.content : null;
},
/**
* Check if the event is encrypted.
* @return {boolean} True if this event is encrypted.

View File

@@ -185,14 +185,8 @@ function PushProcessor(client) {
const eventFulfillsDisplayNameCondition = function(cond, ev) {
let content = ev.getContent();
// TODO: Don't use private variable access
if (ev.isEncrypted() && ev._clearEvent) {
// Sometimes the event content is nested for some reason, so unpack that.
if (ev._clearEvent.content) {
content = ev._clearEvent.content;
} else {
content = ev._clearEvent;
}
if (ev.isEncrypted() && ev.getClearContent()) {
content = ev.getClearContent();
}
if (!content || !content.body || typeof content.body != 'string') {
return false;