diff --git a/src/appservice/Api.ts b/src/appservice/Api.ts index 18ab9161..73716957 100644 --- a/src/appservice/Api.ts +++ b/src/appservice/Api.ts @@ -87,6 +87,7 @@ export class Api { } // TODO: getMjolnir can fail if the ownerId doesn't match the requesting userId. + // https://github.com/matrix-org/mjolnir/issues/408 const mjolnir = this.mjolnirManager.getMjolnir(mjolnirId, userId); if (mjolnir === undefined) { response.status(400).send("unknown mjolnir mxid"); @@ -143,6 +144,7 @@ export class Api { } // TODO: provisionNewMjolnir will throw if it fails... + // https://github.com/matrix-org/mjolnir/issues/408 const [mjolnirId, managementRoom] = await this.mjolnirManager.provisionNewMjolnir(userId); response.status(200).json({ mxid: mjolnirId, roomId: managementRoom }); @@ -180,6 +182,7 @@ export class Api { } // TODO: getMjolnir can fail if the ownerId doesn't match the requesting userId. + // https://github.com/matrix-org/mjolnir/issues/408 const mjolnir = this.mjolnirManager.getMjolnir(mjolnirId, userId); if (mjolnir === undefined) { response.status(400).send("unknown mjolnir mxid"); diff --git a/src/appservice/AppService.ts b/src/appservice/AppService.ts index 81eac03c..c664cc44 100644 --- a/src/appservice/AppService.ts +++ b/src/appservice/AppService.ts @@ -74,13 +74,6 @@ export class MjolnirAppService { // is it ok for this to be async? seems a bit dodge. // it should be BridgeRequestEvent not whatever this is public async onEvent(request: Request, context: BridgeContext) { - // https://github.com/matrix-org/matrix-appservice-irc/blob/develop/src/bridge/MatrixHandler.ts#L921 - // ^ that's how matrix-appservice-irc maps from room to channel, we basically need to do the same but map - // from room to which mjolnir it's for, unless that information is present in BridgeContext, which it might be... - // How do we get that information in bridge context? - // Alternatively we have to either use their advanced user member caching or track this ourselves somehow ffs. - // Alternatively just don't care about it right now, let it push events through to them all and get - // consultation from bridge people (Halfy). const mxEvent = request.getData(); if ('m.room.member' === mxEvent.type) { if ('invite' === mxEvent.content['membership'] && mxEvent.state_key === this.bridge.botUserId) { diff --git a/src/appservice/MjolnirManager.ts b/src/appservice/MjolnirManager.ts index 7c4a9d50..d22363e0 100644 --- a/src/appservice/MjolnirManager.ts +++ b/src/appservice/MjolnirManager.ts @@ -93,13 +93,13 @@ export class MjolnirManager { public getOwnedMjolnirs(ownerId: string): ManagedMjolnir[] { // TODO we need to use the database for this but also provide the utility // for going from a MjolnirRecord to a ManagedMjolnir. + // https://github.com/matrix-org/mjolnir/issues/409 return [...this.mjolnirs.values()].filter(mjolnir => mjolnir.ownerId !== ownerId); } public onEvent(request: Request, context: BridgeContext) { - // We honestly don't know how we're going to map from bridge to user - // https://github.com/matrix-org/matrix-appservice-bridge/blob/6046d31c54d461ad53e6d6e244ce2d944b62f890/src/components/room-bridge-store.ts - // looks like it might work, but we will ask, figure it out later. + // TODO We need a way to map a room id (that the event is from) to a set of managed mjolnirs that should be informed. + // https://github.com/matrix-org/mjolnir/issues/412 [...this.mjolnirs.values()].forEach((mj: ManagedMjolnir) => mj.onEvent(request)); } @@ -152,6 +152,7 @@ export class MjolnirManager { } // TODO: We need to check that an owner still has access to the appservice each time they send a command to the mjolnir or use the web api. + // https://github.com/matrix-org/mjolnir/issues/410 /** * Used at startup to create all the ManagedMjolnir instances and start them so that they will respond to users. */ @@ -190,6 +191,7 @@ export class ManagedMjolnir { this.mjolnir.client.emit('room.message', mxEvent.room_id, mxEvent); } // TODO: We need to figure out how to inform the mjolnir of `room.join`. + // https://github.com/matrix-org/mjolnir/issues/411 } if (mxEvent['type'] === 'm.room.member') { if (mxEvent['content']['membership'] === 'invite' && mxEvent.state_key === await this.mjolnir.client.getUserId()) {