Files
portabase/src/db/schema/09_notification-channel.ts
T
MalilavGitHubkillian-larcherCharles GTEgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>github-actions[bot] <github-actions[bot]@users.noreply.github.com>Michael KutýKillian Larchergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>Shawn M
130c23dd5b feat: Add Microsoft Teams as notification provider (issue 260) (#313)
* feat: add Microsoft Teams notification provider

* feat: Add Microsoft Teams as notification provider

* fix: Update database migration

* fix: Remove duplicate file 0058 db migration

* add Microsoft Teams notification provider E2E tests

* fix: externalize e2e testings and profile name trim (#318)

* fix: externalize e2e testings

* fix: externalize e2e tests.

* refactor: improve e2e workflow.

* chore: upgrade workflow action version.

* fix: createEnv by adding emptyStringAsUndefined (#317)

* chore: release 1.18.2

---------

Co-authored-by: killian-larcher <killian.larcher@soluce-technologies.com>
Co-authored-by: Charles GTE <charles.gauthereau@soluce-technologies.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix(layout): guard undefined user.name in avatar fallbacks (#320)

* fix(layout): guard undefined user.name in avatar fallbacks

* fix: AUTH_DEFAULT_USER as zod email

---------

Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>

* fix: profile name trim

---------

Co-authored-by: killian-larcher <killian.larcher@soluce-technologies.com>
Co-authored-by: Charles GTE <charles.gauthereau@soluce-technologies.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Michael Kutý <6du1ro.n@gmail.com>
Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>

* chore: release 1.18.3

* chore: Update README.md (#323)

* chore: Update README.md

added unraid link

* chore: Update README.md

fix markdown

* chore: release 1.18.4

* fix: teams.ts with timeout

---------

Co-authored-by: Killian Larcher <98161034+KillianLarcher@users.noreply.github.com>
Co-authored-by: killian-larcher <killian.larcher@soluce-technologies.com>
Co-authored-by: Charles GTE <charles.gauthereau@soluce-technologies.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Michael Kutý <6du1ro.n@gmail.com>
Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>
Co-authored-by: Shawn M <84647313+hyperion02@users.noreply.github.com>
2026-06-19 07:42:50 +02:00

60 lines
2.4 KiB
TypeScript

import {boolean, jsonb, pgEnum, pgTable, primaryKey, unique, uuid, varchar} from "drizzle-orm/pg-core";
import {timestamps} from "@/db/schema/00_common";
import {MemberWithUser, Organization, organization} from "@/db/schema/03_organization";
import {relations} from "drizzle-orm";
import {createSelectSchema} from "drizzle-zod";
import {z} from "zod";
import {OrganizationInvitation} from "@/db/schema/05_invitation";
export const providerKindEnum = pgEnum('provider_kind', ['slack', 'smtp', 'discord', 'telegram', 'gotify', 'ntfy', 'webhook', 'nextcloud', 'teams']);
export const notificationChannel = pgTable('notification_channel', {
id: uuid("id").defaultRandom().primaryKey(),
provider: providerKindEnum('provider').notNull(),
organizationId: uuid("organization_id").references(() => organization.id, {onDelete: "cascade"}),
name: varchar('name', {length: 255}).notNull(),
config: jsonb('config').notNull(),
enabled: boolean('enabled').default(false).notNull(),
...timestamps
});
export const organizationNotificationChannel = pgTable(
"organization_notification_channels",
{
organizationId: uuid('organization_id')
.notNull()
.references(() => organization.id, {onDelete: 'cascade'}),
notificationChannelId: uuid('notification_channel_id')
.notNull()
.references(() => notificationChannel.id, {onDelete: 'cascade'}),
},
(t) => [unique().on(t.organizationId, t.notificationChannelId)]
);
export const notificationChannelRelations = relations(notificationChannel, ({many}) => ({
organizations: many(organizationNotificationChannel),
}));
export const organizationNotificationChannelRelations = relations(organizationNotificationChannel, ({one}) => ({
organization: one(organization, {
fields: [organizationNotificationChannel.organizationId],
references: [organization.id],
}),
notificationChannel: one(notificationChannel, {
fields: [organizationNotificationChannel.notificationChannelId],
references: [notificationChannel.id],
}),
}));
export const notificationChannelSchema = createSelectSchema(notificationChannel);
export type NotificationChannel = z.infer<typeof notificationChannelSchema>;
export type NotificationChannelWith = NotificationChannel & {
organizations: {
organizationId: string;
notificationChannelId: string;
}[];
};