defined notificationSchema outside of class
This commit is contained in:
1 parent
e78dc86aa3
commit
b2fdab0418
1 file changed
+13
-13
@@ -21,6 +21,19 @@ import type { CalendarEvent } from "../interfaces/calendar/calendar-types";
|
|||||||
import type { INotificationsIntegration } from "../interfaces/notifications/notifications-integration";
|
import type { INotificationsIntegration } from "../interfaces/notifications/notifications-integration";
|
||||||
import type { Notification } from "../interfaces/notifications/notification-types";
|
import type { Notification } from "../interfaces/notifications/notification-types";
|
||||||
|
|
||||||
|
const notificationSchema = z.object({
|
||||||
|
ocs: z.object({
|
||||||
|
data: z.array(
|
||||||
|
z.object({
|
||||||
|
notification_id: z.number(),
|
||||||
|
datetime: z.string(),
|
||||||
|
subject: z.string(),
|
||||||
|
message: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
const logger = createLogger({ module: "nextcloudIntegration" });
|
const logger = createLogger({ module: "nextcloudIntegration" });
|
||||||
|
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
@@ -121,19 +134,6 @@ export class NextcloudIntegration extends Integration implements ICalendarIntegr
|
|||||||
|
|
||||||
if (!response.ok) throw new ResponseError(response);
|
if (!response.ok) throw new ResponseError(response);
|
||||||
|
|
||||||
const notificationSchema = z.object({
|
|
||||||
ocs: z.object({
|
|
||||||
data: z.array(
|
|
||||||
z.object({
|
|
||||||
notification_id: z.number(),
|
|
||||||
datetime: z.string(),
|
|
||||||
subject: z.string(),
|
|
||||||
message: z.string(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
const json = notificationSchema.parse(await response.json());
|
const json = notificationSchema.parse(await response.json());
|
||||||
|
|
||||||
return json.ocs.data.map((notification) => ({
|
return json.ocs.data.map((notification) => ({
|
||||||
|
|||||||
Reference in new issue
Block a user