-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added native slack webhook type
- Loading branch information
1 parent
b8f65fc
commit ed5a7d7
Showing
7 changed files
with
289 additions
and
68 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
backend/src/db/migrations/20240702055253_add-encrypted-webhook-url.ts
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { WebhookType } from "@app/services/webhook/webhook-types"; | ||
|
||
import { TableName } from "../schemas"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
const hasEncryptedURL = await knex.schema.hasColumn(TableName.Webhook, "encryptedUrl"); | ||
const hasUrlIV = await knex.schema.hasColumn(TableName.Webhook, "urlIV"); | ||
const hasUrlTag = await knex.schema.hasColumn(TableName.Webhook, "urlTag"); | ||
const hasType = await knex.schema.hasColumn(TableName.Webhook, "type"); | ||
|
||
await knex.schema.alterTable(TableName.Webhook, (tb) => { | ||
if (!hasEncryptedURL) { | ||
tb.text("encryptedUrl"); | ||
} | ||
if (!hasUrlIV) { | ||
tb.string("urlIV"); | ||
} | ||
if (!hasUrlTag) { | ||
tb.string("urlTag"); | ||
} | ||
if (!hasType) { | ||
tb.string("type").defaultTo(WebhookType.GENERAL); | ||
} | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
const hasEncryptedURL = await knex.schema.hasColumn(TableName.Webhook, "encryptedUrl"); | ||
const hasUrlIV = await knex.schema.hasColumn(TableName.Webhook, "urlIV"); | ||
const hasUrlTag = await knex.schema.hasColumn(TableName.Webhook, "urlTag"); | ||
const hasType = await knex.schema.hasColumn(TableName.Webhook, "type"); | ||
|
||
await knex.schema.alterTable(TableName.Webhook, (t) => { | ||
if (hasEncryptedURL) { | ||
t.dropColumn("encryptedUrl"); | ||
} | ||
if (hasUrlIV) { | ||
t.dropColumn("urlIV"); | ||
} | ||
if (hasUrlTag) { | ||
t.dropColumn("urlTag"); | ||
} | ||
if (hasType) { | ||
t.dropColumn("type"); | ||
} | ||
}); | ||
} |
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
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
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
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
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
Oops, something went wrong.