Fix caldav issues (#16297)
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ export class CalDAVClient {
|
||||
if (!this.hasFileExtension(url)) return 'ics';
|
||||
const fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||
|
||||
return fileName.substring(fileName.lastIndexOf('.') + 1);
|
||||
return fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
|
||||
}
|
||||
|
||||
private isValidFormat(url: string): boolean {
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export class CalendarAccountAuthenticationService {
|
||||
}: ValidateAndRefreshConnectedAccountAuthenticationParams): Promise<ConnectedAccountTokens> {
|
||||
if (
|
||||
connectedAccount.provider === ConnectedAccountProvider.IMAP_SMTP_CALDAV &&
|
||||
isDefined(connectedAccount.connectionParameters?.SMTP)
|
||||
isDefined(connectedAccount.connectionParameters?.CALDAV)
|
||||
) {
|
||||
await this.validateCalDavCredentialsForConnectedAccount({
|
||||
connectedAccount,
|
||||
|
||||
+2
-17
@@ -261,7 +261,7 @@ describe('ImapSmtpCalDavAPIService', () => {
|
||||
expect(mockCalendarQueueService.add).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should create both channels when only CALDAV is configured but disable message sync', async () => {
|
||||
it('should only create calendar channel when only CALDAV is configured', async () => {
|
||||
const caldavOnlyInput = {
|
||||
...baseInput,
|
||||
connectionParameters: {
|
||||
@@ -282,7 +282,6 @@ describe('ImapSmtpCalDavAPIService', () => {
|
||||
const expectedCalendarChannel = {
|
||||
id: 'mocked-uuid',
|
||||
connectedAccountId: 'mocked-uuid',
|
||||
|
||||
handle: 'test@example.com',
|
||||
};
|
||||
|
||||
@@ -292,21 +291,7 @@ describe('ImapSmtpCalDavAPIService', () => {
|
||||
|
||||
await service.processAccount(caldavOnlyInput);
|
||||
|
||||
expect(mockMessageChannelRepository.save).toHaveBeenCalledWith(
|
||||
{
|
||||
id: 'mocked-uuid',
|
||||
connectedAccountId: 'mocked-uuid',
|
||||
type: MessageChannelType.EMAIL,
|
||||
handle: 'test@example.com',
|
||||
isSyncEnabled: false,
|
||||
syncStatus: MessageChannelSyncStatus.NOT_SYNCED,
|
||||
syncStage: MessageChannelSyncStage.PENDING_CONFIGURATION,
|
||||
pendingGroupEmailsAction: MessageChannelPendingGroupEmailsAction.NONE,
|
||||
syncCursor: '',
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
{},
|
||||
);
|
||||
expect(mockMessageChannelRepository.save).not.toHaveBeenCalled();
|
||||
expect(mockCalendarChannelRepository.save).toHaveBeenCalled();
|
||||
|
||||
expect(mockMessageQueueService.add).not.toHaveBeenCalled();
|
||||
|
||||
+21
-17
@@ -138,25 +138,29 @@ export class ImapSmtpCalDavAPIService {
|
||||
accountId: string,
|
||||
messageChannelRepository: WorkspaceRepository<MessageChannelWorkspaceEntity>,
|
||||
): Promise<MessageChannelWorkspaceEntity | null> {
|
||||
const shouldEnableSync = Boolean(input.connectionParameters.IMAP);
|
||||
const shouldCreateMessageChannel = Boolean(input.connectionParameters.IMAP);
|
||||
|
||||
const newMessageChannel = await messageChannelRepository.save(
|
||||
{
|
||||
id: v4(),
|
||||
connectedAccountId: accountId,
|
||||
type: MessageChannelType.EMAIL,
|
||||
handle: input.handle,
|
||||
isSyncEnabled: shouldEnableSync,
|
||||
syncStatus: MessageChannelSyncStatus.NOT_SYNCED,
|
||||
syncStage: MessageChannelSyncStage.PENDING_CONFIGURATION,
|
||||
pendingGroupEmailsAction: MessageChannelPendingGroupEmailsAction.NONE,
|
||||
syncCursor: '',
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
{},
|
||||
);
|
||||
if (shouldCreateMessageChannel) {
|
||||
const newMessageChannel = await messageChannelRepository.save(
|
||||
{
|
||||
id: v4(),
|
||||
connectedAccountId: accountId,
|
||||
type: MessageChannelType.EMAIL,
|
||||
handle: input.handle,
|
||||
isSyncEnabled: true,
|
||||
syncStatus: MessageChannelSyncStatus.NOT_SYNCED,
|
||||
syncStage: MessageChannelSyncStage.PENDING_CONFIGURATION,
|
||||
pendingGroupEmailsAction: MessageChannelPendingGroupEmailsAction.NONE,
|
||||
syncCursor: '',
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
return shouldEnableSync ? newMessageChannel : null;
|
||||
return newMessageChannel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private async setupCalendarChannels(
|
||||
|
||||
Reference in New Issue
Block a user