simple-slack-api icon indicating copy to clipboard operation
simple-slack-api copied to clipboard

SlackChannel.getMembers() is not updated after establishing a connection

Open wollekuel opened this issue 8 years ago • 2 comments

Looks like the list of the members of a channel/group is not updated after establishing a connection to Slack. SlackChannel.getMembers() returns only the list of the members that was up-to-date at the time of connection establishment.

Since I need the current information about the participating users of a channel/group I had to implement it by myself using postGenericSlackCommand().

wollekuel avatar Jun 24 '16 15:06 wollekuel

There is a session.refetchUsers() that wil replace the getMembers or the users member in the session object with the contents of a postGenericSlackCommand() with the command users.list

In hindsight the session.users should be using a Concurrent Hashmap instead of a hashmap and the refetch users should probably merge the found with the old and avoid duplicates incase the post to slack api does not come back "ok". The postGenericSlackCommand() should also check for "OK" on the rest response as per the Slack API documentation.

You can also add a listener to users added or joined

BobbyJohansen avatar Oct 04 '16 02:10 BobbyJohansen

Thanks for the comment. Doing a session.refetchUsers() before using getMembers() works fine and saves some lines of code...

wollekuel avatar Oct 06 '16 15:10 wollekuel