Skip to content

Remove legacy "autoReadPattern" slack. #9761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment explaining that this column was deprecated in favor of autoReadChannelPatterns for future reference. Something like:

Suggested change
ALTER TABLE slack_configurations DROP COLUMN "autoReadChannelPattern";
-- Migration created on Jan 06, 2025
-- Drop legacy autoReadChannelPattern column which was deprecated in favor of autoReadChannelPatterns
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
14 changes: 0 additions & 14 deletions connectors/src/resources/slack_configuration_resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,6 @@ export class SlackConfigurationResource extends BaseResource<SlackConfigurationM
return new Ok(undefined);
}

async setAutoReadChannelPattern(pattern: string | null) {
await this.model.update(
{ autoReadChannelPattern: pattern },
{
where: {
id: this.id,
},
}
);
return new Ok(undefined);
}

async setAutoReadChannelPatterns(patterns: SlackAutoReadPattern[]) {
await this.model.update(
{ autoReadChannelPatterns: patterns },
Expand Down Expand Up @@ -318,8 +306,6 @@ export class SlackConfigurationResource extends BaseResource<SlackConfigurationM

toJSON(): SlackConfigurationType {
return {
// TODO(2025-01-02 AutoReadCleanUp) Remove once fully migrated to `autoReadChannelPatterns`.
autoReadChannelPattern: this.autoReadChannelPattern,
autoReadChannelPatterns: this.autoReadChannelPatterns,
botEnabled: this.botEnabled,
whitelistedDomains: this.whitelistedDomains?.map((d) => d),
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
Loading