You've already forked matrix-js-sdk
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:
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user