From 06a32ce0a1ad2a7e00ddf09685a92f5c71e86662 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 8 Aug 2019 15:15:25 +0100 Subject: [PATCH 1/8] Add matrix base API to report an event Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/base-apis.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index 6a3d59083..54e530b66 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -2,6 +2,7 @@ Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd Copyright 2019 The Matrix.org Foundation C.I.C. +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -1991,6 +1992,23 @@ MatrixBaseApis.prototype.agreeToTerms = function( ); }; +/** + * Reports an event as inappropriate to the server, which may then notify the appropriate people. + * @param {string} roomId The room in which the event being reported is located. + * @param {string} eventId The event to report. + * @param {number} score The score to rate this content as where -100 is most offensive and 0 is inoffensive. + * @param {string} reason The reason the content is being reported. May be blank. + * @returns {module:client.Promise} Resolves to an empty object if successful + */ +MatrixBaseApis.prototype.reportEvent = function(roomId, eventId, score, reason) { + const path = utils.encodeUri("/rooms/$roomId/report/$eventId", { + $roomId: roomId, + $eventId: eventId, + }); + + return this._http.authedRequest(undefined, "POST", path, null, {score, reason}); +}; + /** * MatrixBaseApis object */ From 0a487ec43ef6a2266fc4a631f8eca531ca9442af Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 1 Sep 2019 18:05:12 -0600 Subject: [PATCH 2/8] Add Synapse admin functions for deactivating a user For https://github.com/matrix-org/matrix-react-sdk/pull/3371 --- src/client.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/client.js b/src/client.js index af01a6d32..31acf47ec 100644 --- a/src/client.js +++ b/src/client.js @@ -3886,6 +3886,55 @@ MatrixClient.prototype.getTurnServers = function() { return this._turnServers || []; }; +// Synapse-specific APIs +// ===================== + +/** + * Determines if the current user is an administrator of the Synapse homeserver. + * Returns false if untrue or the homeserver does not appear to be a Synapse + * homeserver. This function is implementation specific and may change + * as a result. + * @return {boolean} true if the user appears to be a Synapse administrator. + */ +MatrixClient.prototype.isSynapseAdministrator = function() { + return this.whoisSynapseUser(this.getUserId()) + .then(() => true) + .catch(() => false); +}; + +/** + * Performs a whois lookup on a user using Synapse's administrator API. + * This function is implementation specific and may change as a + * result. + * @param {string} userId the User ID to look up. + * @return {object} the whois response - see Synapse docs for information. + */ +MatrixClient.prototype.whoisSynapseUser = function(userId) { + const path = utils.encodeUri( + "/_synapse/admin/v1/whois/$userId", + { $userId: userId }, + ); + return this._http.authedRequest( + undefined, 'GET', path, undefined, undefined, {prefix: ''}, + ); +}; + +/** + * Deactivates a user using Synapse's administrator API. This + * function is implementation specific and may change as a result. + * @param {string} userId the User ID to deactivate. + * @return {object} the deactive response - see Synapse docs for information. + */ +MatrixClient.prototype.deactivateSynapseUser = function(userId) { + const path = utils.encodeUri( + "/_synapse/admin/v1/deactivate/$userId", + { $userId: userId }, + ); + return this._http.authedRequest( + undefined, 'POST', path, undefined, undefined, {prefix: ''}, + ); +}; + // Higher level APIs // ================= From 8143ce84501752f01f8ef903541d4699bd621594 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 2 Sep 2019 11:06:54 -0600 Subject: [PATCH 3/8] Update src/client.js Co-Authored-By: J. Ryan Stinnett --- src/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 31acf47ec..efdeea3ce 100644 --- a/src/client.js +++ b/src/client.js @@ -3923,7 +3923,7 @@ MatrixClient.prototype.whoisSynapseUser = function(userId) { * Deactivates a user using Synapse's administrator API. This * function is implementation specific and may change as a result. * @param {string} userId the User ID to deactivate. - * @return {object} the deactive response - see Synapse docs for information. + * @return {object} the deactivate response - see Synapse docs for information. */ MatrixClient.prototype.deactivateSynapseUser = function(userId) { const path = utils.encodeUri( From e9bc3f26a5f277e59003ddaddffb575d3516fd57 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Fri, 13 Sep 2019 16:13:27 +0100 Subject: [PATCH 4/8] Prepare changelog for v2.3.2-rc.1 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43a77b8b3..da1439252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +Changes in [2.3.2-rc.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v2.3.2-rc.1) (2019-09-13) +========================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v2.3.1...v2.3.2-rc.1) + + * Synapse admin functions to release + [\#1033](https://github.com/matrix-org/matrix-js-sdk/pull/1033) + * [To Release] Add matrix base API to report an event + [\#1032](https://github.com/matrix-org/matrix-js-sdk/pull/1032) + Changes in [2.3.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v2.3.1) (2019-09-12) ================================================================================================ [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v2.3.1-rc.1...v2.3.1) From f21c5aa7f2d986fb26b4cafaea14f37d1edd6490 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Fri, 13 Sep 2019 16:13:27 +0100 Subject: [PATCH 5/8] v2.3.2-rc.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b9817777..20b2a7d86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-js-sdk", - "version": "2.3.1", + "version": "2.3.2-rc.1", "description": "Matrix Client-Server SDK for Javascript", "main": "index.js", "scripts": { From 39dc6a174206eab20b48392900cd2ed070634425 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 28 Aug 2019 16:34:09 -0400 Subject: [PATCH 6/8] Fix addPendingEvent with pending event order == chronological When the pending event order setting was set to 'chronological' (the default) `addPendingEvent` would NPE because Room no longer has a `this._filter` property. It should get the filter from the event timeline set instead, as it does in the previous line when checking or the presence of a filter. We should strongly consider changing the default pending event order to 'detached' and probably removing 'chronological' or comitting to support it properly: it's not really tested and is prone to breakage like this. Applies flumpt's fix from https://github.com/matrix-org/matrix-js-sdk/issues/599 Fixes https://github.com/matrix-org/matrix-js-sdk/issues/599 --- src/models/room.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/room.js b/src/models/room.js index 625dc0f0a..453546f0f 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -1187,7 +1187,7 @@ Room.prototype.addPendingEvent = function(event, txnId) { for (let i = 0; i < this._timelineSets.length; i++) { const timelineSet = this._timelineSets[i]; if (timelineSet.getFilter()) { - if (this._filter.filterRoomTimeline([event]).length) { + if (timelineSet.getFilter().filterRoomTimeline([event]).length) { timelineSet.addEventToTimeline(event, timelineSet.getLiveTimeline(), false); } @@ -1216,7 +1216,7 @@ Room.prototype._aggregateNonLiveRelation = function(event) { for (let i = 0; i < this._timelineSets.length; i++) { const timelineSet = this._timelineSets[i]; if (timelineSet.getFilter()) { - if (this._filter.filterRoomTimeline([event]).length) { + if (timelineSet.getFilter().filterRoomTimeline([event]).length) { timelineSet.aggregateRelations(event); } } else { From f8ff3aac5845e5aeeaa50e69ecdc1ca84660c185 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 16 Sep 2019 17:40:19 +0100 Subject: [PATCH 7/8] Prepare changelog for v2.3.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da1439252..cf53a7930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Changes in [2.3.2](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v2.3.2) (2019-09-16) +================================================================================================ +[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v2.3.2-rc.1...v2.3.2) + + * [Release] Fix addPendingEvent with pending event order == chronological + [\#1034](https://github.com/matrix-org/matrix-js-sdk/pull/1034) + Changes in [2.3.2-rc.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v2.3.2-rc.1) (2019-09-13) ========================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v2.3.1...v2.3.2-rc.1) From 7d07ab7c7ec388e30765b74968e468c6d3512da7 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 16 Sep 2019 17:40:19 +0100 Subject: [PATCH 8/8] v2.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20b2a7d86..373079ce5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-js-sdk", - "version": "2.3.2-rc.1", + "version": "2.3.2", "description": "Matrix Client-Server SDK for Javascript", "main": "index.js", "scripts": {