mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 08:50:50 +08:00
fix(server): test & schema
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user