mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
add managementRoomId
to provisionNewMjolnir
This commit is contained in:
parent
c1d79a698b
commit
6d604190a4
@ -89,13 +89,11 @@ export class Api {
|
||||
return;
|
||||
}
|
||||
|
||||
const managementRoom = request.params.query["roomId"] || null;
|
||||
const managementRoom = request.params.query["roomId"];
|
||||
|
||||
const userId = await this.resolveAccessToken(accessToken);
|
||||
const mjolnirId = this.appService.provisionNewMjolnir(
|
||||
userId,
|
||||
// method doesn't take a managementRoom yet
|
||||
//managementRoom,
|
||||
userId, managementRoom,
|
||||
);
|
||||
|
||||
// privisionNewMjolnir can't fail yet, but it should be able to
|
||||
|
@ -41,7 +41,7 @@ class MjolnirAppService {
|
||||
});
|
||||
}
|
||||
|
||||
public async provisionNewMjolnir(requestingUserId: string) {
|
||||
public async provisionNewMjolnir(requestingUserId: string, managementRoomId: string|undefined) {
|
||||
// FIXME: we need to restrict who can do it (special list? ban remote users?)
|
||||
const issuedMjolnirs = await this.bridge.getUserStore()!.getRemoteUsersFromMatrixId(requestingUserId);
|
||||
if (issuedMjolnirs.length === 0) {
|
||||
@ -51,7 +51,7 @@ class MjolnirAppService {
|
||||
// we're only doing this because it's complaining about missing profiles.
|
||||
// actually the user id wasn't even right, so this might not be necessary anymore.
|
||||
await mjIntent.ensureProfile('Mjolnir');
|
||||
this.mjolnirManager.createNew(requestingUserId, mjIntent);
|
||||
this.mjolnirManager.createNew(requestingUserId, managementRoomId, mjIntent);
|
||||
// Technically the mjolnir is a remote user, but also not because it's matrix-matrix.
|
||||
//const mjAsRemote = new RemoteUser(mjIntent.userId)
|
||||
//const bridgeStore = this.bridge.getUserStore()!;
|
||||
|
@ -11,7 +11,7 @@ export class MjolnirManager {
|
||||
return setDefaults({managementRoom});
|
||||
}
|
||||
|
||||
public async createNew(requestingUserId: string, intent: Intent) {
|
||||
public async createNew(requestingUserId: string, managementRoomId: string|undefined, intent: Intent) {
|
||||
// FIXME: We should be creating the intent here and generating the id surely?
|
||||
// rather than externally...
|
||||
// FIXME: We need to verify that we haven't stored a mjolnir already if we aren't doing the above.
|
||||
@ -19,18 +19,19 @@ export class MjolnirManager {
|
||||
// get mjolnir list wroking by just avoiding it for now and see if protections work
|
||||
// and bans.
|
||||
// Find out trade offs of changing mjolnir to make it work vs making new subcomponent of mjolnir.
|
||||
const managementRoomId = (await intent.createRoom({
|
||||
createAsClient: true,
|
||||
options: {
|
||||
preset: 'private_chat',
|
||||
invite: [requestingUserId],
|
||||
name: `${requestingUserId}'s mjolnir`
|
||||
}
|
||||
})).room_id;
|
||||
if (managementRoomId === undefined) {
|
||||
managementRoomId = (await intent.createRoom({
|
||||
createAsClient: true,
|
||||
options: {
|
||||
preset: 'private_chat',
|
||||
invite: [requestingUserId],
|
||||
name: `${requestingUserId}'s mjolnir`
|
||||
}
|
||||
})).room_id;
|
||||
}
|
||||
const managedMjolnir = new ManagedMjolnir(intent, await Mjolnir.setupMjolnirFromConfig(intent.matrixClient, this.getDefaultMjolnirConfig(managementRoomId)));
|
||||
await managedMjolnir.moveMeSomewhereCommonAndStopImplementingFunctionalityOnACommandFirstBasis(requestingUserId, 'list')
|
||||
this.mjolnirs.set(intent.userId, managedMjolnir);
|
||||
|
||||
}
|
||||
|
||||
public onEvent(request: Request<WeakEvent>, context: BridgeContext) {
|
||||
|
Loading…
Reference in New Issue
Block a user