fix(nextcloud): correct calendar event date mapping and support showU… (#3330)
Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
@@ -1,6 +1,3 @@
|
|||||||
import dayjs from "dayjs";
|
|
||||||
import objectSupport from "dayjs/plugin/objectSupport";
|
|
||||||
import utc from "dayjs/plugin/utc";
|
|
||||||
import * as ical from "node-ical";
|
import * as ical from "node-ical";
|
||||||
import { DAVClient } from "tsdav";
|
import { DAVClient } from "tsdav";
|
||||||
import type { Dispatcher, RequestInit as UndiciFetchRequestInit } from "undici";
|
import type { Dispatcher, RequestInit as UndiciFetchRequestInit } from "undici";
|
||||||
@@ -15,9 +12,6 @@ import { Integration } from "../base/integration";
|
|||||||
import type { TestingResult } from "../base/test-connection/test-connection-service";
|
import type { TestingResult } from "../base/test-connection/test-connection-service";
|
||||||
import type { CalendarEvent } from "../calendar-types";
|
import type { CalendarEvent } from "../calendar-types";
|
||||||
|
|
||||||
dayjs.extend(utc);
|
|
||||||
dayjs.extend(objectSupport);
|
|
||||||
|
|
||||||
@HandleIntegrationErrors([integrationTsdavHttpErrorHandler])
|
@HandleIntegrationErrors([integrationTsdavHttpErrorHandler])
|
||||||
export class NextcloudIntegration extends Integration {
|
export class NextcloudIntegration extends Integration {
|
||||||
protected async testingAsync(input: IntegrationTestingInput): Promise<TestingResult> {
|
protected async testingAsync(input: IntegrationTestingInput): Promise<TestingResult> {
|
||||||
@@ -27,7 +21,7 @@ export class NextcloudIntegration extends Integration {
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getCalendarEventsAsync(start: Date, end: Date): Promise<CalendarEvent[]> {
|
public async getCalendarEventsAsync(start: Date, end: Date, _showUnmonitored?: boolean): Promise<CalendarEvent[]> {
|
||||||
const client = await this.createCalendarClientAsync();
|
const client = await this.createCalendarClientAsync();
|
||||||
await client.login();
|
await client.login();
|
||||||
|
|
||||||
@@ -57,14 +51,7 @@ export class NextcloudIntegration extends Integration {
|
|||||||
|
|
||||||
logger.debug(`Converting VEVENT event to ${event.etag} from Nextcloud: ${JSON.stringify(veventObject)}`);
|
logger.debug(`Converting VEVENT event to ${event.etag} from Nextcloud: ${JSON.stringify(veventObject)}`);
|
||||||
|
|
||||||
const date = dayjs.utc({
|
const date = veventObject.start;
|
||||||
days: veventObject.start.getDay(),
|
|
||||||
month: veventObject.start.getMonth(),
|
|
||||||
year: veventObject.start.getFullYear(),
|
|
||||||
hours: veventObject.start.getHours(),
|
|
||||||
minutes: veventObject.start.getMinutes(),
|
|
||||||
seconds: veventObject.start.getSeconds(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const eventUrlWithoutHost = new URL(event.url).pathname;
|
const eventUrlWithoutHost = new URL(event.url).pathname;
|
||||||
const dateInMillis = veventObject.start.valueOf();
|
const dateInMillis = veventObject.start.valueOf();
|
||||||
@@ -75,7 +62,7 @@ export class NextcloudIntegration extends Integration {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: veventObject.summary,
|
name: veventObject.summary,
|
||||||
date: date.toDate(),
|
date,
|
||||||
subName: "",
|
subName: "",
|
||||||
description: veventObject.description,
|
description: veventObject.description,
|
||||||
links: [
|
links: [
|
||||||
|
|||||||
Reference in New Issue
Block a user