Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions packages/trpc/src/router/device/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,6 @@ import { protectedProcedure } from "../../trpc";
* the rest of v1.
*/
export const deviceRouter = {
/**
* @deprecated Kept for backwards compat with shipped desktop/mobile clients
* that still call heartbeat on a 30s interval. Same logic as registerDevice.
*/
heartbeat: protectedProcedure
.input(
z.object({
deviceId: z.string().min(1),
deviceName: z.string().min(1),
deviceType: z.enum(deviceTypeValues),
}),
)
.mutation(async ({ ctx, input }) => {
const organizationId = ctx.activeOrganizationId;
if (!organizationId) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "No active organization selected",
});
}

const userId = ctx.session.user.id;
const now = new Date();

await db
.insert(devicePresence)
.values({
userId,
organizationId,
deviceId: input.deviceId,
deviceName: input.deviceName,
deviceType: input.deviceType,
lastSeenAt: now,
createdAt: now,
})
.onConflictDoUpdate({
target: [devicePresence.userId, devicePresence.deviceId],
set: {
deviceName: input.deviceName,
deviceType: input.deviceType,
lastSeenAt: now,
organizationId,
},
});

return { success: true };
}),

/**
* Register device presence (called once on app startup).
* Upserts a row so MCP can verify device ownership.
Expand Down
Loading