1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Modify addRoomToGroup to allow setting isPublic, create alias updateGroupRoomAssociation

The API on synapse was modified to be an upsert, which means the same API call for adding a room to a group can be used to update the visibility of that association.
This commit is contained in:
Luke Barnard
2017-11-02 13:34:34 +00:00
parent 51883b8f11
commit d40cc795f7

View File

@@ -561,17 +561,30 @@ MatrixBaseApis.prototype.removeRoomFromGroupSummary = function(groupId, roomId)
/** /**
* @param {string} groupId * @param {string} groupId
* @param {string} roomId * @param {string} roomId
* @param {bool} isPublic Whether the room-group association is visible to non-members
* @return {module:client.Promise} Resolves: Empty object * @return {module:client.Promise} Resolves: Empty object
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixBaseApis.prototype.addRoomToGroup = function(groupId, roomId) { MatrixBaseApis.prototype.addRoomToGroup = function(groupId, roomId, isPublic) {
if (isPublic === undefined) {
isPublic = true;
}
const path = utils.encodeUri( const path = utils.encodeUri(
"/groups/$groupId/admin/rooms/$roomId", "/groups/$groupId/admin/rooms/$roomId",
{$groupId: groupId, $roomId: roomId}, {$groupId: groupId, $roomId: roomId},
); );
return this._http.authedRequest(undefined, "PUT", path, undefined, {}); return this._http.authedRequest(undefined, "PUT", path, undefined,
{ visibility: { type: isPublic ? "public" : "private" } },
);
}; };
/**
* Alias for addRoomToGroup.
* @see module:base-apis.addRoomToGroup
*/
MatrixBaseApis.prototype.updateGroupRoomAssociation =
MatrixBaseApis.prototype.addRoomToGroup;
/** /**
* @param {string} groupId * @param {string} groupId
* @param {string} roomId * @param {string} roomId
@@ -657,7 +670,7 @@ MatrixBaseApis.prototype.getPublicisedGroups = function(userIds) {
/** /**
* @param {string} groupId * @param {string} groupId
* @param {bool} isPublic Whether the user's mebership of this group is made public * @param {bool} isPublic Whether the user's membership of this group is made public
* @return {module:client.Promise} Resolves: Empty object * @return {module:client.Promise} Resolves: Empty object
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */