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

Merge pull request #1463 from matrix-org/travis/fix-3pid-createRoom

Inject identity server token for 3pid invites on createRoom
This commit is contained in:
Travis Ralston
2020-09-10 07:05:01 -06:00
committed by GitHub

View File

@@ -462,8 +462,26 @@ MatrixBaseApis.prototype.getFallbackAuthUrl = function(loginType, authSessionId)
* room_alias: {string(opt)}}</code> * room_alias: {string(opt)}}</code>
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixBaseApis.prototype.createRoom = function(options, callback) { MatrixBaseApis.prototype.createRoom = async function(options, callback) {
// valid options include: room_alias_name, visibility, invite // some valid options include: room_alias_name, visibility, invite
// inject the id_access_token if inviting 3rd party addresses
const invitesNeedingToken = (options.invite_3pid || [])
.filter(i => !i.id_access_token);
if (
invitesNeedingToken.length > 0 &&
this.identityServer &&
this.identityServer.getAccessToken &&
await this.doesServerAcceptIdentityAccessToken()
) {
const identityAccessToken = await this.identityServer.getAccessToken();
if (identityAccessToken) {
for (const invite of invitesNeedingToken) {
invite.id_access_token = identityAccessToken;
}
}
}
return this._http.authedRequest( return this._http.authedRequest(
callback, "POST", "/createRoom", undefined, options, callback, "POST", "/createRoom", undefined, options,
); );