mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* 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]>
26 lines
904 B
TypeScript
26 lines
904 B
TypeScript
import logger from "@calcom/lib/logger";
|
|
import type { IUrlShortenerProvider, ShortenOptions, ShortenResult } from "../IUrlShortenerProvider";
|
|
import type { SinkClient } from "./SinkClient";
|
|
|
|
const log = logger.getSubLogger({ prefix: ["sink-shortener"] });
|
|
|
|
export class SinkShortener implements IUrlShortenerProvider {
|
|
constructor(private client: SinkClient) {}
|
|
|
|
static isConfigured(): boolean {
|
|
return Boolean(process.env.SINK_API_URL && process.env.SINK_API_KEY);
|
|
}
|
|
|
|
async shortenMany(urls: string[], _options?: ShortenOptions): Promise<ShortenResult[]> {
|
|
try {
|
|
const results = await this.client.createMany(urls);
|
|
return results.map((result) => ({
|
|
shortLink: result.shortLink || result.url,
|
|
}));
|
|
} catch (error) {
|
|
log.error("Sink shortening failed, returning original URLs", error);
|
|
return urls.map((url) => ({ shortLink: url }));
|
|
}
|
|
}
|
|
}
|