Skip to content

Commit

Permalink
Remove legacy "autoReadPattern" slack.
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Jan 6, 2025
1 parent 89ae37a commit 12e178d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 39 deletions.
2 changes: 2 additions & 0 deletions connectors/migrations/db/migration_43.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Migration created on Jan 06, 2025
ALTER TABLE slack_configurations DROP COLUMN "autoReadChannelPattern";
31 changes: 0 additions & 31 deletions connectors/src/connectors/slack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class SlackConnectorManager extends BaseConnectorManager<SlackConfigurati
dataSourceId: dataSourceConfig.dataSourceId,
},
{
autoReadChannelPattern: configuration.autoReadChannelPattern,
autoReadChannelPatterns: configuration.autoReadChannelPatterns,
botEnabled: configuration.botEnabled,
slackTeamId: teamInfo.team.id,
Expand Down Expand Up @@ -709,10 +708,6 @@ export class SlackConnectorManager extends BaseConnectorManager<SlackConfigurati
}
}

case "autoReadChannelPattern": {
return new Err(new Error("autoReadChannelPattern is not deprecated"));
}

case "autoReadChannelPatterns": {
const parsedConfig = safeParseJSON(configValue);
if (parsedConfig.isErr()) {
Expand Down Expand Up @@ -764,14 +759,6 @@ export class SlackConnectorManager extends BaseConnectorManager<SlackConfigurati
return new Ok(botEnabledRes.value.toString());
}

case "autoReadChannelPattern": {
const autoReadChannelPattern = await getAutoReadChannelPattern(
this.connectorId
);

return autoReadChannelPattern;
}

case "autoReadChannelPatterns": {
const autoReadChannelPatterns = await getAutoReadChannelPatterns(
this.connectorId
Expand Down Expand Up @@ -878,24 +865,6 @@ export async function uninstallSlack(connectionId: string) {
return new Ok(undefined);
}

export async function getAutoReadChannelPattern(
connectorId: ModelId
): Promise<Result<string | null, Error>> {
const slackConfiguration =
await SlackConfigurationResource.fetchByConnectorId(connectorId);
if (!slackConfiguration) {
return new Err(
new Error(
`Failed to find a Slack configuration for connector ${connectorId}`
)
);
}
if (!slackConfiguration.autoReadChannelPattern) {
return new Ok(null);
}
return new Ok(slackConfiguration.autoReadChannelPattern);
}

export async function getAutoReadChannelPatterns(
connectorId: ModelId
): Promise<Result<string | null, Error>> {
Expand Down
6 changes: 0 additions & 6 deletions connectors/src/lib/models/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class SlackConfigurationModel extends BaseModel<SlackConfigurationModel>
declare connectorId: ForeignKey<ConnectorModel["id"]>;
// Whitelisted domains are in the format "domain:group_id".
declare whitelistedDomains?: readonly string[];
declare autoReadChannelPattern?: string | null;
declare autoReadChannelPatterns: SlackAutoReadPattern[];
}

Expand Down Expand Up @@ -47,11 +46,6 @@ SlackConfigurationModel.init(
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true,
},
// TODO(2025-01-02 AutoReadCleanUp) Remove once fully migrated to `autoReadChannelPatterns`.
autoReadChannelPattern: {
type: DataTypes.STRING,
allowNull: true,
},
autoReadChannelPatterns: {
type: DataTypes.JSONB,
allowNull: true,
Expand Down
2 changes: 0 additions & 2 deletions types/src/connectors/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export function isSlackAutoReadPatterns(
export const SlackConfigurationTypeSchema = t.type({
botEnabled: t.boolean,
whitelistedDomains: t.union([t.array(t.string), t.undefined]),
// TODO(2025-01-02 AutoReadCleanUp) Remove once fully migrated to `autoReadChannelPatterns`.
autoReadChannelPattern: t.union([t.string, t.null, t.undefined]),
autoReadChannelPatterns: SlackAutoReadPatternsSchema,
});

Expand Down

0 comments on commit 12e178d

Please sign in to comment.