RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.
https://rocketchat.github.io/Rocket.Chat.Apps-engine/
MIT License
116 stars 118 forks source link

Cannot add room member on executePreRoomCreateExtend #96

Open dizzy opened 6 years ago

dizzy commented 6 years ago

Hi All,

I am trying to add a bot to newly created rooms by implementing IPreRoomCreateExtend and executePreRoomCreateExtend function:

public async executePreRoomCreateExtend(room: IRoom, extend: IRoomExtender, read: IRead, http: IHttp, persistence: IPersistence): Promise<IRoom> {
        const bot = await read.getUserReader().getById('rocket.cat');
        this.getLogger().info(bot);
        return extend.addMember(bot).getRoom();
}

I can see in app logs that executePreRoomCreateExtend is called and bot object returned OK but not added to the extended room. When I log the extended Room I see it has proper creator property but null members ("members": null). I've also tried to add custom fields to Room using IRoomExtender.addCustomField method and this works just fine so it gets down to adding members to newly created rooms.

➔ ±--------------------------------------------------+ ➔ | SERVER RUNNING | ➔ ±--------------------------------------------------+ ➔ | | ➔ | Rocket.Chat Version: 0.71.1 | ➔ | NodeJS Version: 8.11.3 - x64 | ➔ | Platform: linux | ➔ | Process Port: 3000 | ➔ | Site URL: https://localhost | ➔ | ReplicaSet OpLog: Disabled | ➔ | Commit Hash: e73dc78ffd | ➔ | Commit Branch: HEAD | ➔ | | ➔ ±--------------------------------------------------+

API version 1.2.1

Thanks!

d-gubert commented 5 years ago

Hi.

Yeah, this looks like a bug in the engine; it's storing the members but not passing them to the room. Will label it as a bug and it may come out in the next release

P.S: PRs are welcome ;)

dizzy commented 5 years ago

thanks @d-gubert ! will send a PR when get some time for!