Commit Graph

72 Commits

Author SHA1 Message Date
faaefd6c31 fix: correct User table name in bot migration FK
The User model has no @@map so its table is "User" (PascalCase),
not "users". The FK reference was wrong.
2026-03-03 21:47:15 +01:00
f42c51db3b fix: remove url from schema datasource (Prisma 7.x)
Prisma 7.x no longer supports 'url' in the schema datasource block.
The URL is provided exclusively via prisma.config.ts.
2026-03-03 21:45:05 +01:00
ed5ff3db43 fix: exclude bot/ from Next.js build and lint
tsconfig.json included **/*.ts but only excluded worker/**, not bot/**.
This caused next build to type-check bot source files whose dependencies
aren't installed in the root node_modules, breaking CI.

- Add bot/** to tsconfig.json exclude array
- Add bot/** and worker/** to eslint globalIgnores
2026-03-03 21:42:34 +01:00
575ffdbc31 feat: Docker audit + Telegram bot service + send UI
Docker:
- Harden docker-compose.yml: parameterized DB creds, required AUTH_SECRET,
  health checks, resource limits, network isolation, removed exposed DB port
- Add profiles (telegram/bot/full) so base 'docker compose up' needs only AUTH_SECRET
- Fix docker-entrypoint.sh: AUTH_SECRET startup guard
- Fix Dockerfile: copy prisma.config.ts + dotenv into production image
- Update .env.example with all new variables
- Update .dockerignore

Telegram Bot Service (bot/):
- TDLib-based bot using bot token auth (not HTTP Bot API)
- Commands: /search, /latest, /package, /link, /unlink, /subscribe, /unsubscribe
- pg_notify listener for send requests (bot_send) and new packages (new_package)
- Subscription-based notifications when matching packages arrive
- Dockerfile with multi-stage build (bookworm-slim for glibc/TDLib)

API & Database:
- Prisma: TelegramLink, BotSendRequest, BotSubscription models + migration
- POST /api/telegram/bot/send - queue package delivery to linked TG account
- GET /api/telegram/bot/send/[id] - poll send request status
- Server actions: generateTelegramLinkCode, unlinkTelegram, getBotSendHistory
- Worker: emit pg_notify('new_package') after creating packages

Frontend:
- Settings: TelegramLinkCard for account linking via one-time code
- STL table + drawer: SendToTelegramButton with send dialog and status polling
- Telegram admin: Bot Sends tab with delivery history table
- Shared SendHistoryRow type

README: Updated with bot docs, profiles, config vars, project structure
2026-03-03 21:36:57 +01:00
xCyanGrizzly
4d0df6b1a4 addd TG integration 2026-03-02 11:57:17 +01:00
xCyanGrizzly
b427193d17 feat: add Telegram integration with forum topic support and creator tracking
Adds full Telegram ZIP ingestion pipeline: TDLib worker service scans source
channels for archive files, deduplicates by content hash, extracts metadata,
uploads to archive channel, and indexes in Postgres. Forum supergroups are
scanned per-topic with topic names used as creator. Filename-based creator
extraction (e.g. "Mammoth Factory - 2026-01.zip") serves as fallback.

Includes admin UI for managing accounts/channels, simplified account setup
(API credentials via env vars), auth code/password submission dialog,
package browser with creator column, and live ingestion activity tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:02:06 +01:00
xCyanGrizzly
beb9cfb312 Add log usage buttons on main page and seperate page 2026-02-19 11:46:19 +01:00
xCyanGrizzly
32683ecf5e added other materials tab 2026-02-18 21:55:39 +01:00
xCyanGrizzly
ec04e1bd0b add docker compose 2026-02-18 20:05:16 +01:00
xCyanGrizzly
5f12c8425b fix: use prisma-client-js generator — prisma-client requires custom output
The prisma-client generator mandates an output path, which conflicts
with using the standard @prisma/client import. Switch to prisma-client-js
which generates to node_modules by default.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-18 19:52:37 +01:00
xCyanGrizzly
46cb517b8d fix: use standard @prisma/client imports instead of custom output path
The custom generator output to src/generated/prisma caused persistent
Turbopack module resolution failures in CI. Switch to the standard
@prisma/client import path which all bundlers resolve correctly.

- Remove custom output from prisma schema generator
- Update all imports from ../generated/prisma to @prisma/client
- Add postinstall script to auto-run prisma generate after npm ci
- Remove generated files from git (no longer needed in source tree)
- Simplify CI workflow (remove verify step and --webpack workaround)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-18 19:49:53 +01:00
xCyanGrizzly
e70bdda511 fix: use webpack build in CI to bypass Turbopack resolution bug
Turbopack cannot resolve imports from src/generated/prisma even
with relative paths and committed files. Switch to --webpack for
CI build. Also add file verification step for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:49:00 +01:00
xCyanGrizzly
8436a0e875 fix: use relative imports for generated Prisma client
Turbopack cannot resolve @/generated/prisma path alias during
next build, even with the files committed and baseUrl set.
Switch to relative imports (../generated/prisma) which Turbopack
resolves without issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:44:43 +01:00
xCyanGrizzly
23e233fe02 fix: commit generated Prisma client — Turbopack excludes gitignored paths
Turbopack skips gitignored directories during module resolution in
next build. Since src/generated/prisma was in .gitignore, the build
on CI failed with "Module not found: Can't resolve '@/generated/prisma'"
even though prisma generate created the files.

Fix: commit the generated client and remove it from .gitignore.
Run `npx prisma generate` after schema changes to update.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:34:19 +01:00
xCyanGrizzly
57ce1bffb2 fix: remove standalone tsc step — next build handles type checking
The standalone `npx tsc --noEmit` can't resolve @/ path aliases
for generated Prisma client files on CI, even with baseUrl set.
next build already runs TypeScript type checking and ESLint via
its own bundler which handles path aliases correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:29:27 +01:00
xCyanGrizzly
b8a939a4f6 ci: add prisma generate diagnostics to debug TS2307
Add ls output after prisma generate to verify files exist
before tsc runs. This will show whether the generated client
is in src/generated/prisma/ or elsewhere.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:23:15 +01:00
xCyanGrizzly
0f001e70d1 fix: add baseUrl to tsconfig for path alias resolution in CI
tsc requires baseUrl to be set for paths mapping to work.
Without it, @/* path aliases are silently ignored during
standalone tsc --noEmit, causing TS2307 errors for
@/generated/prisma imports in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:20:23 +01:00
xCyanGrizzly
c7a9b78ffb fix: make DATABASE_URL available to all CI steps and add prisma verify
- Move DATABASE_URL to workflow-level env so all steps can access it
- Add verification step to confirm prisma generate creates output files
- This should fix TS2307 'Cannot find module @/generated/prisma' in CI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 17:13:30 +01:00
xCyanGrizzly
36d403cef5 fix: track migration_lock.toml required by prisma migrate deploy
The migration_lock.toml was excluded by a gitignore pattern
(prisma/migrations/**/migration_lock.toml) which caused
`prisma migrate deploy` to fail in CI with no lock file present.
Prisma requires this file to be version-controlled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 16:07:28 +01:00
xCyanGrizzly
a6fd8ca877 fix: suppress remaining ESLint warnings blocking CI
- Disable react-hooks/incompatible-library warnings for RHF watch()
  and TanStack useReactTable() — these are false positives from the
  React Compiler plugin
- Remove unused useDebounce import and variable from vendor-table

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 15:51:28 +01:00
xCyanGrizzly
564f81585b fix eslint errors 2026-02-18 15:27:23 +01:00
xCyanGrizzly
3a5726e82b Init 2026-02-18 14:26:36 +01:00