Skip to content

Commit

Permalink
Adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric committed Apr 4, 2024
1 parent d710dea commit 5aa0fa4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
20 changes: 10 additions & 10 deletions connectors/migrations/20240324_slackbot_whitelist.sql
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
INSERT INTO
slack_bots_whitelist("connectorId", "botName")
slack_bots_whitelist("connectorId", "slackConfigurationId", "botName")
VALUES
(5, 'Beaver');
(5, 3, 'Beaver');

INSERT INTO
slack_bots_whitelist("connectorId", "botName")
slack_bots_whitelist("connectorId", "slackConfigurationId", "botName")
VALUES
(14, 'feedback-hackaton');
(14, 5, 'feedback-hackaton');

INSERT INTO
slack_bots_whitelist("connectorId", "botName")
slack_bots_whitelist("connectorId", "slackConfigurationId", "botName")
VALUES
(722, 'Retool');
(722, 158, 'Retool');

INSERT INTO
slack_bots_whitelist("connectorId", "botName")
slack_bots_whitelist("connectorId", "slackConfigurationId", "botName")
VALUES
(211, 'DustWorkflowTest');
(211, 50, 'DustWorkflowTest');

INSERT INTO
slack_bots_whitelist("connectorId", "botName")
slack_bots_whitelist("connectorId", "slackConfigurationId", "botName")
VALUES
(211, 'dust-email-lists-highlights');
(211, 50, 'dust-email-lists-highlights');
4 changes: 2 additions & 2 deletions connectors/src/admin/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
NotionPage,
} from "@connectors/lib/models/notion";
import {
SlackBotWhitelist,
SlackBotWhitelistModel,
SlackChannel,
SlackChatBotMessage,
SlackConfigurationModel,
Expand All @@ -62,7 +62,7 @@ async function main(): Promise<void> {
await SlackMessages.sync({ alter: true });
await SlackChannel.sync({ alter: true });
await SlackChatBotMessage.sync({ alter: true });
await SlackBotWhitelist.sync({ alter: true });
await SlackBotWhitelistModel.sync({ alter: true });
await NotionPage.sync({ alter: true });
await NotionDatabase.sync({ alter: true });
await NotionConnectorState.sync({ alter: true });
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/connectors/slack/lib/workspace_limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {} from "@slack/web-api/dist/response/UsersInfoResponse";
import type { SlackUserInfo } from "@connectors/connectors/slack/lib/slack_client";
import { getSlackConversationInfo } from "@connectors/connectors/slack/lib/slack_client";
import { dataSourceConfigFromConnector } from "@connectors/lib/api/data_source_config";
import { SlackBotWhitelist } from "@connectors/lib/models/slack";
import { SlackBotWhitelistModel } from "@connectors/lib/models/slack";
import logger from "@connectors/logger/logger";
import type { ConnectorResource } from "@connectors/resources/connector_resource";

Expand Down Expand Up @@ -214,7 +214,7 @@ async function isBotAllowed(
// that talks to our bot (@dust) will be able to use the Dust bot.
// Make sure to be explicit about this with users as you whitelist a new bot.
// Example: non-verfied-user -> @AnyWhitelistedBot -> @dust -> Dust answers with potentially private information.
const whitelist = await SlackBotWhitelist.findOne({
const whitelist = await SlackBotWhitelistModel.findOne({
where: {
connectorId: connector.id,
botName: names,
Expand Down
12 changes: 7 additions & 5 deletions connectors/src/lib/models/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,19 @@ SlackChatBotMessage.init(
);
ConnectorModel.hasOne(SlackChatBotMessage);

export class SlackBotWhitelist extends Model<
InferAttributes<SlackBotWhitelist>,
InferCreationAttributes<SlackBotWhitelist>
export class SlackBotWhitelistModel extends Model<
InferAttributes<SlackBotWhitelistModel>,
InferCreationAttributes<SlackBotWhitelistModel>
> {
declare id: CreationOptional<number>;
declare createdAt: CreationOptional<Date>;
declare updatedAt: CreationOptional<Date>;
declare botName: string;
declare connectorId: ForeignKey<ConnectorModel["id"]>;
declare slackConfiguration: ForeignKey<SlackConfigurationModel["id"]>;
}

SlackBotWhitelist.init(
SlackBotWhitelistModel.init(
{
id: {
type: DataTypes.INTEGER,
Expand Down Expand Up @@ -332,4 +333,5 @@ SlackBotWhitelist.init(
}
);

ConnectorModel.hasMany(SlackBotWhitelist);
ConnectorModel.hasMany(SlackBotWhitelistModel);
SlackConfigurationModel.hasMany(SlackBotWhitelistModel);

0 comments on commit 5aa0fa4

Please sign in to comment.