Reputation: 623
I'm trying to develop a little script that fetches all the users from a channel. I managed to do it, but it retrieves much more users than the ones that are currently on the channel (on the app are 102, on the request I get 202). After checking the documentation I see that it gives back also the deleted/deactivated users. I try to filter with if (user.deleted == false) but it happens that all the users (even the ones that are not included in the channel anymore) have deleted as false.
How could I just get the activated users, or at least get info about which users are deleted/deactivated in order to filter them? I'm researching for some time now but I don't find any answer, I would really appreciate some help.
This is the request:
const generalChannelRes = await web.conversations.members('C02Q3F80V', { limit: 500 })
try {
let fixture = await Promise.all(generalChannelRes.members.map(async userId => {
const user = await web.users.info(userId)
if (!user.deleted) {
const userData = [user.user.profile.email, user.user.name]
return userData
}}))
fixture = fixture.filter(u => u)
fs.writeFileSync('./models/fixture-users-new.json', JSON.stringify(fixture, null,
2))
})
}
Upvotes: 1
Views: 579
Reputation: 623
The issue was very silly, the check on the conditional statement I was using was wrong, doing if (!user.user.deleted)
I can get the activated/not-deleted users :)
Upvotes: 1