From d44d63c1d6f65aa879e7b1348f96724cef73d583 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 4 Jan 2018 21:55:20 +0000 Subject: [PATCH 1/3] Send sticker message in to a room. --- src/client.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/client.js b/src/client.js index 6fb28058221..5933433f3d7 100644 --- a/src/client.js +++ b/src/client.js @@ -1317,6 +1317,31 @@ MatrixClient.prototype.sendImageMessage = function(roomId, url, info, text, call return this.sendMessage(roomId, content, callback); }; +/** + * @param {string} roomId + * @param {string} url + * @param {Object} info + * @param {string} text + * @param {module:client.callback} callback Optional. + * @return {module:client.Promise} Resolves: TODO + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixClient.prototype.sendStickerMessage = function(roomId, url, info, text, callback) { + if (utils.isFunction(text)) { + callback = text; text = undefined; + } + if (!text) { + text = "Sticker"; + } + const content = { + msgtype: "m.sticker", + url: url, + info: info, + body: text, + }; + return this.sendMessage(roomId, content, callback); +}; + /** * @param {string} roomId * @param {string} body From aef27d811ae6d49e014c30af19a14f3f5997ff18 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sat, 6 Jan 2018 00:13:24 +0000 Subject: [PATCH 2/3] Set sticker type on event instead of message type. --- src/client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index 5933433f3d7..e1596bb40d5 100644 --- a/src/client.js +++ b/src/client.js @@ -1334,12 +1334,13 @@ MatrixClient.prototype.sendStickerMessage = function(roomId, url, info, text, ca text = "Sticker"; } const content = { - msgtype: "m.sticker", url: url, info: info, body: text, }; - return this.sendMessage(roomId, content, callback); + return this.sendEvent( + roomId, "m.room.sticker", content, callback, undefined, + ); }; /** From 90045b6faa5904ecd4185bf1f3a021f6b3396e74 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 8 Jan 2018 11:18:36 +0000 Subject: [PATCH 3/3] Fix filtering. --- src/filter-component.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/filter-component.js b/src/filter-component.js index ebf1dd0f430..38b1c8afdd8 100644 --- a/src/filter-component.js +++ b/src/filter-component.js @@ -97,11 +97,12 @@ FilterComponent.prototype._checkFields = }; const self = this; - Object.keys(literal_keys).forEach(function(name) { + for (let n=0; n < Object.keys(literal_keys).length; n++) { + const name = Object.keys(literal_keys)[n]; const match_func = literal_keys[name]; const not_name = "not_" + name; const disallowed_values = self[not_name]; - if (disallowed_values.map(match_func)) { + if (disallowed_values.filter(match_func).length > 0) { return false; } @@ -111,7 +112,7 @@ FilterComponent.prototype._checkFields = return false; } } - }); + } const contains_url_filter = this.filter_json.contains_url; if (contains_url_filter !== undefined) {