You've already forked matrix-js-sdk
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:
@@ -519,6 +519,17 @@ utils.extend(module.exports.MatrixEvent.prototype, {
|
|||||||
decryptionResult.forwardingCurve25519KeyChain || [];
|
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.
|
* Check if the event is encrypted.
|
||||||
* @return {boolean} True if this event is encrypted.
|
* @return {boolean} True if this event is encrypted.
|
||||||
|
|||||||
@@ -185,14 +185,8 @@ function PushProcessor(client) {
|
|||||||
|
|
||||||
const eventFulfillsDisplayNameCondition = function(cond, ev) {
|
const eventFulfillsDisplayNameCondition = function(cond, ev) {
|
||||||
let content = ev.getContent();
|
let content = ev.getContent();
|
||||||
// TODO: Don't use private variable access
|
if (ev.isEncrypted() && ev.getClearContent()) {
|
||||||
if (ev.isEncrypted() && ev._clearEvent) {
|
content = ev.getClearContent();
|
||||||
// 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 (!content || !content.body || typeof content.body != 'string') {
|
if (!content || !content.body || typeof content.body != 'string') {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user