INNER CODE UNIT · TypeScript

getActiveDevices

raj457036/CopyCat-Clipboard · supabase/functions/manage_sync_devices/index.ts:55

async function getActiveDevices(
  client: SupabaseClient,
  userId: string,
) {
  const activeSince = new Date(
    Date.now() - DEVICE_ACTIVITY_WINDOW_DAYS * 24 * 60 * 60 * 1000,
  ).toISOString();

  const { data, error } = await client
    .from(DEVICES_TABLE)
    .select("deviceId, platform, appVersion, isRevoked, last_seen_at")
    .eq("userId", userId)
    .eq("isRevoked", false)
    .gte("last_seen_at", activeSince)
    .order("last_seen_at", { ascending: false });

  if (error) throw new Error(error.message);
  return data ?? [];

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…