simple-slack-api
simple-slack-api copied to clipboard
SlackChannel.getMembers() is not updated after establishing a connection
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().
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
Thanks for the comment. Doing a session.refetchUsers() before using getMembers() works fine and saves some lines of code...