mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 00:02:37 +10:00
feat(client api): keep track of last connected
This commit is contained in:
@ -5,7 +5,7 @@ import prisma from "../db/database";
|
||||
|
||||
export type EventHandlerFunction<T> = (
|
||||
h3: H3Event<EventHandlerRequest>,
|
||||
utils: ClientUtils,
|
||||
utils: ClientUtils
|
||||
) => Promise<T> | T;
|
||||
|
||||
type ClientUtils = {
|
||||
@ -82,7 +82,7 @@ export function defineClientEventHandler<T>(handler: EventHandlerFunction<T>) {
|
||||
});
|
||||
if (!client)
|
||||
throw new Error(
|
||||
"client util fetch client broke - this should NOT happen",
|
||||
"client util fetch client broke - this should NOT happen"
|
||||
);
|
||||
return client;
|
||||
}
|
||||
@ -97,7 +97,7 @@ export function defineClientEventHandler<T>(handler: EventHandlerFunction<T>) {
|
||||
|
||||
if (!client)
|
||||
throw new Error(
|
||||
"client util fetch client broke - this should NOT happen",
|
||||
"client util fetch client broke - this should NOT happen"
|
||||
);
|
||||
|
||||
return client.user;
|
||||
@ -109,6 +109,11 @@ export function defineClientEventHandler<T>(handler: EventHandlerFunction<T>) {
|
||||
fetchUser,
|
||||
};
|
||||
|
||||
prisma.client.update({
|
||||
where: { id: clientId },
|
||||
data: { lastConnected: new Date() },
|
||||
});
|
||||
|
||||
return await handler(h3, utils);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user