Files
Amit SharmaGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Keith Williams
353f71bdc6 feat: Sink url shortner for sms workflow reminders (#26608)
* feat: Sink url shortner for sms workflow reminders

* fix: remove hardcoded dub values

* update .env.example

* fix: unit tests

* chore: add tests for scheduleSmsReminder and utils

* review refactor

* fix: type check

* review refactor

* fix: update test to account for smsReminderNumber fallback from main

Co-Authored-By: unknown <>

* feat: add feature flag for sink and more tests to verify

* fix: type check

* use proper feature flags for sink

* Apply suggestion from @keithwillcode

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Keith Williams <[email protected]>
2026-03-16 20:51:28 +00:00

44 lines
1.4 KiB
TypeScript

import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import prisma from "@calcom/prisma";
import type { IUrlShortenerProvider } from "./IUrlShortenerProvider";
import { DubShortener } from "./providers/DubShortener";
import { NoopShortener } from "./providers/NoopShortener";
import { SinkClient } from "./providers/SinkClient";
import { SinkShortener } from "./providers/SinkShortener";
export class UrlShortenerFactory {
static async create({
userId,
teamId,
}: { userId?: number | null; teamId?: number | null } = {}): Promise<IUrlShortenerProvider> {
if (SinkShortener.isConfigured()) {
const featuresRepository = new FeaturesRepository(prisma);
const globallyEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("sink-shortener");
if (globallyEnabled) {
return new SinkShortener(new SinkClient());
}
if (userId) {
const useSink = await featuresRepository.checkIfUserHasFeature(userId, "sink-shortener");
if (useSink) {
return new SinkShortener(new SinkClient());
}
}
if (teamId) {
const useSink = await featuresRepository.checkIfTeamHasFeature(teamId, "sink-shortener");
if (useSink) {
return new SinkShortener(new SinkClient());
}
}
}
if (DubShortener.isConfigured()) {
return new DubShortener();
}
return new NoopShortener();
}
}