fix(server): test & schema

This commit is contained in:
DarkSky
2026-05-04 03:56:14 +08:00
parent 74d5ebad13
commit 1ad088398f
4 changed files with 119 additions and 72 deletions
@@ -571,18 +571,28 @@ export class CalendarService {
}
async assertCanLinkProvider(userId: string, provider: CalendarProviderName) {
if (this.canCreateNewAccounts(provider)) {
return;
}
const accounts = await this.models.calendarAccount.listByUser(userId);
if (accounts.some(account => account.provider === provider)) {
if (await this.canLinkProvider(userId, provider)) {
return;
}
throw this.providerLinkDisabledError(provider);
}
async canLinkProvider(
userId: string | null | undefined,
provider: CalendarProviderName
) {
if (this.canCreateNewAccounts(provider)) {
return true;
}
if (!userId) {
return false;
}
const accounts = await this.models.calendarAccount.listByUser(userId);
return accounts.some(account => account.provider === provider);
}
getAuthUrl(
provider: CalendarProviderName,
state: string,