Skip to content

Commit

Permalink
Document remaining issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnuxie committed Nov 7, 2022
1 parent 818e4cf commit ec4cb2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/appservice/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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");
Expand Down
7 changes: 0 additions & 7 deletions src/appservice/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<WeakEvent>, 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) {
Expand Down
8 changes: 5 additions & 3 deletions src/appservice/MjolnirManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<WeakEvent>, 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));
}

Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit ec4cb2e

Please sign in to comment.