2025-06-30 18:58:24 +02:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
*/
|
2025-06-23 00:17:22 +02:00
|
|
|
import { readSubscriptions } from "~/server/database";
|
2025-06-11 21:05:17 +02:00
|
|
|
import type { ApiSession } from "~/shared/types/api";
|
2025-03-07 12:41:57 +01:00
|
|
|
|
2025-06-11 21:05:17 +02:00
|
|
|
export default defineEventHandler(async (event): Promise<ApiSession | undefined> => {
|
2025-06-09 16:51:05 +02:00
|
|
|
const session = await getServerSession(event);
|
2025-03-07 12:41:57 +01:00
|
|
|
if (!session)
|
|
|
|
return;
|
2025-03-07 14:11:07 +01:00
|
|
|
const subscriptions = await readSubscriptions();
|
|
|
|
const push = Boolean(
|
|
|
|
subscriptions.find(sub => sub.type === "push" && sub.sessionId === session.id)
|
|
|
|
);
|
2025-03-07 12:41:57 +01:00
|
|
|
|
2025-06-09 16:51:05 +02:00
|
|
|
await refreshServerSession(event, session);
|
2025-03-11 16:30:51 +01:00
|
|
|
|
2025-03-07 12:41:57 +01:00
|
|
|
return {
|
|
|
|
id: session.id,
|
2025-06-23 00:17:22 +02:00
|
|
|
account: session.account,
|
2025-03-07 14:11:07 +01:00
|
|
|
push,
|
|
|
|
};
|
2025-03-07 12:41:57 +01:00
|
|
|
})
|