This repository was archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from alex-exe/main
Pagination support, Emoji fixed
- Loading branch information
Showing
3 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
import {slack} from "../services/slack.js"; | ||
import channels from "../stores/channels.js"; | ||
|
||
export async function updateChannels() { | ||
try { | ||
const channelsList = await slack.client.conversations.list({ | ||
types: "public_channel,private_channel,mpim,im", | ||
}); | ||
await channels.actions.setChannels(channelsList.channels) | ||
let channelsList = []; | ||
let cursor = undefined; | ||
|
||
while (true) { | ||
const result = await slack.client.conversations.list({ | ||
types: "public_channel,private_channel,mpim,im", | ||
cursor: cursor, | ||
limit: 1000 // maximum allowed by Slack API | ||
}); | ||
|
||
channelsList = channelsList.concat(result.channels); | ||
|
||
if (!result.response_metadata || !result.response_metadata.next_cursor) { | ||
break; | ||
} | ||
|
||
cursor = result.response_metadata.next_cursor; | ||
} | ||
|
||
await channels.actions.setChannels(channelsList) | ||
} | ||
catch (error) { | ||
console.error(error); | ||
console.log(error) | ||
} | ||
} | ||
|
||
await updateChannels() | ||
await updateChannels() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
import {slack} from "../services/slack.js"; | ||
import users from "../stores/users.js"; | ||
|
||
export async function updateUsers() { | ||
try { | ||
const usersList = await slack.client.users.list(); | ||
await users.actions.setUsers(usersList.members) | ||
let usersList = []; | ||
let cursor = undefined; | ||
|
||
while (true) { | ||
const result = await slack.client.users.list({ | ||
cursor: cursor, | ||
limit: 1000 // maximum allowed by Slack API | ||
}); | ||
|
||
usersList = usersList.concat(result.members); | ||
|
||
if (!result.response_metadata || !result.response_metadata.next_cursor) { | ||
break; | ||
} | ||
|
||
cursor = result.response_metadata.next_cursor; | ||
} | ||
|
||
await users.actions.setUsers(usersList) | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
await updateUsers() | ||
await updateUsers() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters