Rocket.Chat.Apps-engine
Rocket.Chat.Apps-engine copied to clipboard
"method not implemented" when using RoomRead.getMembers(roomId)
Hi,
we are trying create an app that creates a room name dynamically via the usernames, but within the executePreRoomCreateModify we are not able to figure out the usernames.
We also first tried to use the usernames property but stumpled upon this issue https://github.com/RocketChat/Rocket.Chat.Apps-engine/issues/58
Is there a different way with an implemented method? Or any other idea on how to fix this? :)
It also would help if we just had access to the IDs of the users within the room...
thanks in advance
Sadly, there is currently no way to get users which are in a room. :( Rodrigo is currently working on implementing items to allow getting users in a room.
Thanks for the fast response!
I see.... Well at least we know now that it is planned, so there is something to look forward for :)
Yeah, one of my Apps broke in the latest updates (Out of Office) due to the usernames removal, so I feel the pain.
Oh that's unfortunate. Kinda the basics of a chat though, users and messages :/ But great to hear that someone is working on it! Is there any issue I can subscribe to?
Currently there's no issue or pull request to watch, however there is a branch: https://github.com/RocketChat/Rocket.Chat.Apps-engine/tree/usernames-getter which this issue is a good one to watch.
1.2.1 has been released, however, it doesn't fix the exact issue reported here.
But it does fix the room.usernames. They used to not have the usernames of the users in the rooms, but it does now.
thank you very much, that might be enough for us :)
Hi @graywolf336, thank you very much for the changes and keeping us up-to-date!
we are trying create an app that creates a room name dynamically via the usernames, but within the executePreRoomCreateModify we are not able to figure out the usernames.
I tried to update the app @sharpner mentioned.
- After upgrading Rocket.Chat to
0.71.0, our app detail page stated 'Failed to fetch'. - After setting the
requiredApiVersionin theapp.jsonfrom^0.9.13(found in several existing apps) to^1.2.1(Is that correct?), I still got 'Failed to fetch'.
Taking a deeper look, the AppApiManager. listApis() resulted in No app found for the provided id..
Could you give us a hint what might be wrong?
- Is the App actually installed?
- If so, is it activated?
- Can you connect with me on our Open Community server, that way we can investigate further..
outdated
- Yes 👍
- It was installed just before I upgraded Rocket.Chat. Then, after having the 'Failed to fetch', I humbly tried to remove the app by dropping it from the
rocketchat_app_*mongo collections (uninstall via UI wasn't possible). - Then, after a second install (now with the updated
requiredApiVersion), the same error appeared.
- Correct, it was activated in both cases.
- I'll investigate my issue, once again, and come back to you asap - connecting with you via https://open.rocket.chat.
So, I got my app going by bootstrapping it from scratch. 👍
Today, I installed Rocket.Chat 0.72.0-rc.1. As far as I understand, that contains https://github.com/RocketChat/Rocket.Chat.Apps-engine/pull/97 and https://github.com/RocketChat/Rocket.Chat/pull/12680. So I gave it another try. Remember: The main goal is to retrieve the user list of a room before the actual room creation.
So I created a dummy application with the following two hooks (pre & post room creation).
Dummy code
# for both executePreRoomCreateModify & executePostRoomCreateModify
async execute(Pre|Post)RoomCreateModify(room: IRoom, builder: IRoomBuilder, read: IRead, http: IHttp, persistence: IPersistence): Promise<IRoom> {
read.getRoomReader().getMembers(room.id)
.then((members: Array<IUser>) =>
this.getLogger().log([members.map((user: IUser) => user.username).join('-')])
);
return room;
}
Result
executePreRoomCreateModify- list of all users of my Rocket.Chat instance. incorrect❗️- Unfortunately,
room.idisundefined(Well, the room hasn't been persisted. So thats reasonable.) - It looks like the query (is it
Subscriptions.getRoomById()?) then falsely return the full user collection, instead of an empty set
- Unfortunately,
executePostRoomCreateModify- list all my room's members. correct ✅
So, now the retrieval of users works - but not for a 'room to be created'. Although I understand, that a db lookup cannot find the room (thus neither the users), I would have been expected a pre room creation hook to receive the incoming data from the client (e.g. a list of plain usernames I sent via the Realtime API).
Do you have a tip of how I might be able to get the plain text version of the incoming data / usernames?
@rodrigok or @d-gubert any ideas on how to achieve the above comment?
the behaviour described by @winterstefan is still happening in v1.3.2. Any updates on this issue?