Rocket.Chat.Apps-engine icon indicating copy to clipboard operation
Rocket.Chat.Apps-engine copied to clipboard

"method not implemented" when using RoomRead.getMembers(roomId)

Open sharpner opened this issue 7 years ago • 14 comments

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

sharpner avatar Oct 23 '18 13:10 sharpner

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.

graywolf336 avatar Oct 23 '18 13:10 graywolf336

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 :)

sharpner avatar Oct 23 '18 14:10 sharpner

Yeah, one of my Apps broke in the latest updates (Out of Office) due to the usernames removal, so I feel the pain.

graywolf336 avatar Oct 23 '18 14:10 graywolf336

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?

sharpner avatar Oct 23 '18 14:10 sharpner

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.

graywolf336 avatar Oct 23 '18 21:10 graywolf336

1.2.1 has been released, however, it doesn't fix the exact issue reported here.

graywolf336 avatar Oct 29 '18 18:10 graywolf336

But it does fix the room.usernames. They used to not have the usernames of the users in the rooms, but it does now.

graywolf336 avatar Oct 29 '18 18:10 graywolf336

thank you very much, that might be enough for us :)

sharpner avatar Oct 30 '18 08:10 sharpner

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.

  1. After upgrading Rocket.Chat to 0.71.0, our app detail page stated 'Failed to fetch'.
  2. After setting the requiredApiVersion in the app.json from ^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?

winterstefan avatar Oct 31 '18 12:10 winterstefan

  1. Is the App actually installed?
  2. If so, is it activated?
  3. Can you connect with me on our Open Community server, that way we can investigate further..

graywolf336 avatar Oct 31 '18 20:10 graywolf336

outdated


  1. 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.
  1. Correct, it was activated in both cases.
  2. I'll investigate my issue, once again, and come back to you asap - connecting with you via https://open.rocket.chat.

winterstefan avatar Nov 05 '18 14:11 winterstefan

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.id is undefined (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
  • 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?

winterstefan avatar Nov 27 '18 08:11 winterstefan

@rodrigok or @d-gubert any ideas on how to achieve the above comment?

graywolf336 avatar Feb 22 '19 22:02 graywolf336

the behaviour described by @winterstefan is still happening in v1.3.2. Any updates on this issue?

sharpner avatar Sep 04 '19 08:09 sharpner