diff --git a/backend/src/routes/doses.ts b/backend/src/routes/doses.ts index 2b9d1ab..0959261 100644 --- a/backend/src/routes/doses.ts +++ b/backend/src/routes/doses.ts @@ -2,7 +2,7 @@ import { FastifyInstance } from "fastify"; import { z } from "zod"; import { db } from "../db/client.js"; import { doseTracking, shareTokens } from "../db/schema.js"; -import { eq, and, gte } from "drizzle-orm"; +import { eq } from "drizzle-orm"; import { requireAuth, getAnonymousUserId } from "../plugins/auth.js"; import { env } from "../plugins/env.js"; import type { AuthUser } from "../types/fastify.js"; @@ -47,17 +47,10 @@ export async function doseRoutes(app: FastifyInstance) { async (request, reply) => { const userId = await getUserId(request, reply); - // Get doses from last 30 days (to avoid loading too much data) - const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); - + // Get all taken doses for this user (no time limit) const doses = await db.select() .from(doseTracking) - .where( - and( - eq(doseTracking.userId, userId), - gte(doseTracking.takenAt, thirtyDaysAgo) - ) - ); + .where(eq(doseTracking.userId, userId)); return { doses: doses.map((d) => ({ @@ -148,17 +141,10 @@ export async function doseRoutes(app: FastifyInstance) { return reply.notFound("Share link not found"); } - // Get doses from last 30 days - const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); - + // Get all taken doses for this user (no time limit) const doses = await db.select() .from(doseTracking) - .where( - and( - eq(doseTracking.userId, share.userId), - gte(doseTracking.takenAt, thirtyDaysAgo) - ) - ); + .where(eq(doseTracking.userId, share.userId)); return { doses: doses.map((d) => ({ diff --git a/backend/src/routes/settings.ts b/backend/src/routes/settings.ts index 0413536..4ebad54 100644 --- a/backend/src/routes/settings.ts +++ b/backend/src/routes/settings.ts @@ -341,7 +341,7 @@ export async function sendShoutrrrNotification(urlStr: string, title: string, me if (urlStr.startsWith("ntfy://")) { const parsed = new URL(urlStr.replace("ntfy://", "https://")); targetUrl = `https://${parsed.host}${parsed.pathname}`; - headers = { "Title": cleanTitle, "Tags": "warning" }; + headers = { "Title": cleanTitle, "Tags": "pill" }; body = message; if (parsed.username && parsed.password) { @@ -349,7 +349,7 @@ export async function sendShoutrrrNotification(urlStr: string, title: string, me } } else if (urlStr.startsWith("https://ntfy.") || urlStr.includes("ntfy.sh") || urlStr.includes("/ntfy/")) { targetUrl = urlStr; - headers = { "Title": cleanTitle, "Tags": "warning" }; + headers = { "Title": cleanTitle, "Tags": "pill" }; body = message; } else if (urlStr.startsWith("http://") || urlStr.startsWith("https://")) { targetUrl = urlStr; diff --git a/backend/src/routes/share.ts b/backend/src/routes/share.ts index c277658..f13c7ac 100644 --- a/backend/src/routes/share.ts +++ b/backend/src/routes/share.ts @@ -81,6 +81,9 @@ export async function shareRoutes(app: FastifyInstance) { // Get user settings for stock thresholds const [settings] = await db.select().from(userSettings).where(eq(userSettings.userId, share.userId)); + // Get the username of the owner who created this share link + const [owner] = await db.select({ username: users.username }).from(users).where(eq(users.id, share.userId)); + // Get medications for this user filtered by takenBy (search in JSON array) // Use SQLite JSON function to check if takenBy is in the array const allMeds = await db.select().from(medications).where(eq(medications.userId, share.userId)); @@ -129,6 +132,7 @@ export async function shareRoutes(app: FastifyInstance) { return { takenBy: share.takenBy, + sharedBy: owner?.username ?? null, scheduleDays: share.scheduleDays, medications: medicationsWithBlisters, stockThresholds: { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 97fcf92..5ddfb82 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3390,6 +3390,7 @@ type SharedMedication = { type SharedScheduleData = { takenBy: string; + sharedBy: string | null; scheduleDays: number; medications: SharedMedication[]; stockThresholds?: { @@ -4086,7 +4087,7 @@ function SharedSchedule() {