Skip to content

Commit 3117e02

Browse files
author
Kian Attari
committed
added whitelist depr. + generic deprecation method
1 parent 18dd9cb commit 3117e02

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/web-api/src/WebClient.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,14 +582,23 @@ function parseRetryHeaders(response: AxiosResponse): number | undefined {
582582
* @param logger instance of web clients logger
583583
*/
584584
function warnDeprecations(method: string, logger: Logger): void {
585-
const deprecatedMethods = ['channels.', 'groups.', 'im.', 'mpim.'];
585+
const deprecatedConversationsMethods = ['channels.', 'groups.', 'im.', 'mpim.'];
586+
587+
const deprecatedMethods = ['admin.conversations.whitelist.'];
588+
589+
const isDeprecatedConversations = deprecatedConversationsMethods.some((depMethod) => {
590+
const re = new RegExp(`^${depMethod}`);
591+
return re.test(method);
592+
});
586593

587594
const isDeprecated = deprecatedMethods.some((depMethod) => {
588595
const re = new RegExp(`^${depMethod}`);
589596
return re.test(method);
590597
});
591598

592-
if (isDeprecated) {
599+
if (isDeprecatedConversations) {
593600
logger.warn(`${method} is deprecated. Please use the Conversations API instead. For more info, go to https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api`);
601+
} else if (isDeprecated) {
602+
logger.warn(`${method} is deprecated. Please check on https://api.slack.com/methods for an alternative.`);
594603
}
595604
}

0 commit comments

Comments
 (0)