Commit Graph

104 Commits

Author SHA1 Message Date
richardtekula
ac429deba3 fix: Remove left artifact from Gablas signature
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 17:34:11 +01:00
richardtekula
d48813b082 fix: Clean up Gablas signature - remove line artifact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 17:30:11 +01:00
richardtekula
e923e42a65 feat: Add 8 certificate templates with different courses and lecturers
Templates:
- AIcertifikat (Zdarílek), AIcertifikatGablas, AIcertifikatPatrik
- ScrumMaster, ScrumProductOwner (blue background)
- ITILFoundation (green background)
- PRINCE2Foundation, PRINCE2Practitioner (orange background)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 17:15:44 +01:00
richardtekula
f7d252ee7b fix: Center course info below participant name in certificates
Layout now:
1. Participant name (centered)
2. Course title (centered, below name)
3. Date range (centered, below course title)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 17:07:36 +01:00
richardtekula
68905787ce fix: Correct positioning of elements in certificate templates
- Position course title below header, not overlapping
- Center participant name above the horizontal line
- Position issue date above "Dátum" text at bottom left
- Use Bahnschrift font for course titles

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:35:50 +01:00
richardtekula
f2af7ffe22 feat: Add certificate templates for Scrum, ITIL, and PRINCE2 courses
- Add 3 new HTML templates: ScrumGeneric, ITIL, PRINCE2
- Add 3 background images: blue (Scrum), green (ITIL), orange (PRINCE2)
- Extract and add signatures: Gablas, Husam
- Update certificate.service.js to support multiple templates with different backgrounds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:22:03 +01:00
richardtekula
12acd68156 refactor: Move course dates from registracie to kurzy table
- Add datumOd and datumDo columns to kurzy table
- Remove datumOd, datumDo, pocetUcastnikov from registracie table
- Update schema, validators, and services accordingly
- Certificate generation now uses course dates
- Migration preserves existing data by copying most recent dates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 12:52:56 +01:00
richardtekula
2fee1f39bc refactor: Extract certificate template to separate file with template selection
- Move HTML template to src/templates/certificates/AIcertifikat.html
- Add template rendering with {{variable}} and {{#if}} syntax
- Add CERTIFICATE_TEMPLATES registry for multiple templates
- Accept templateName parameter in generateCertificate
- Add hasCertificate check to prevent duplicate certificates
- Add hasCertificate field to getCombinedTableData query

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:24:14 +01:00
richardtekula
225936e64a feat: Team leader role permissions, certificate generation, and bug fixes
- Add team_leader access to /admin/users endpoint for user list viewing
- Add PDF certificate generation for AI Kurzy with Puppeteer
- Add certificate assets (background, signatures)
- Add getPrilohaById and download endpoint for attachments
- Fix time tracking service permissions for team_leader
- Fix timesheet controller/service permissions for team_leader
- Fix calendar badge to include reminders in count
- Add lastSeen to message service for online indicator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:58:42 +01:00
richardtekula
a4a81ef88e feat: Multi-feature CRM update
- Add team_leader role with appropriate permissions
- Add lastSeen timestamp for chat online indicator
- Add needsFollowup flag to ucastnici table
- Add getTodayCalendarCount endpoint for calendar badge
- Add company reminders to calendar data
- Enhance company search to include phone and contacts
- Update routes to allow team_leader access to kurzy, services, timesheets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:23:57 +01:00
richardtekula
c3c42ec1e4 docs: Add README with full backend documentation and smoke test checklist
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 10:39:44 +01:00
richardtekula
57e6a2ea45 refactor: Split ai-kurzy.service.js into domain-specific files
Split 445-line monolith into:
- ai-kurzy/kurzy.service.js: course CRUD + stats
- ai-kurzy/ucastnici.service.js: participant CRUD
- ai-kurzy/registracie.service.js: registration CRUD, combined table,
  field updates, and document (prilohy) operations

Original ai-kurzy.service.js becomes a barrel export preserving all
existing import paths.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:43:32 +01:00
richardtekula
37dbf1b177 refactor: Extract notification logic from todo.service.js
Create todo-notification.service.js with:
- notifyNewTodoAssignment(): push notification for new todo assignments
- notifyUpdatedTodoAssignment(): push notification for updated assignments

todo.service.js now delegates to the notification service instead of
containing inline push notification logic with error handling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:42:14 +01:00
richardtekula
240dd5f4c8 refactor: Split company.controller.js into focused controllers
Split company.controller.js (461 lines, 5 concerns) into:
- company.controller.js: CRUD + email (134 lines)
- company-note.controller.js: note operations
- company-reminder.controller.js: reminder operations
- company-team.controller.js: user assignment operations

Update company.routes.js to import from new controllers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:41:31 +01:00
richardtekula
3aba6c2955 refactor: Move audit logging from controllers into services
Add auditContext parameter to service mutating functions. Services now
call audit log functions internally when auditContext is provided.
Controllers pass { userId, ipAddress, userAgent } and no longer import
audit service or fetch extra data for audit purposes.

Files modified:
- 10 service files: added audit imports and auditContext parameter
- 9 controller files: removed audit imports and calls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:39:41 +01:00
richardtekula
caab86079e refactor: Deduplicate event-notifier.js (603 -> 418 lines)
Extract shared helpers:
- getEventsInRange(start, end) replaces getTomorrowEvents + getUpcomingEvents
- groupEventsByUser() deduplicates event grouping logic from 3 functions
- sendNotificationsToUsers() deduplicates notification loop from 3 functions
- buildJmapConfig() removes repeated JMAP config construction

Remove unused standalone range helper functions (getTomorrowRange,
getOneHourRange) — date ranges computed inline where needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:25:35 +01:00
richardtekula
d4883480b2 refactor: Deduplicate time-tracking.service.js (1045 -> 876 lines)
Extract shared helpers:
- validateProjectExists, validateTodoExists, validateCompanyExists,
  validateRelatedEntities (replaces 4x copy-pasted validation blocks)
- generateTimesheetWorkbook (shared workbook creation logic)
- addDailySummary (shared daily totals section)
- saveTimesheetFile (shared file save + DB insert)
- computeDailyTotals, getUserNamePrefix

generateMonthlyTimesheet and generateCompanyTimesheet now use shared
helpers instead of duplicating ~370 lines each.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:24:23 +01:00
richardtekula
4629f1903b refactor: Move inline Zod schemas from routes to validator files
Create ai-kurzy.validators.js and service.validators.js with schemas
extracted from their respective route files. Routes now import schemas
instead of defining them inline.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:22:33 +01:00
richardtekula
f463467264 refactor: Extract shared multer/upload config from routes
Create src/config/upload.js with createUpload() factory and shared
ALLOWED_FILE_TYPES constant. Replace duplicated multer configs in 5
route files with calls to the shared factory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:21:35 +01:00
richardtekula
01ce2fc7ad refactor: Remove unused exports
Remove setPrimaryAccountSchema from email-account.validators.js and
requireOwnerOrAdmin from roleMiddleware.js — both have zero imports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:20:00 +01:00
richardtekula
938a8d1478 refactor: Delete unused utility files
Remove queryBuilder.js and pagination.js — zero imports anywhere in codebase.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:19:39 +01:00
richardtekula
883d3fa533 chore: Commit current state before refactoring
Includes deleted sql/ files, seeds, and documentation files.
Prepares master for refactoring branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:19:23 +01:00
richardtekula
95688be45b feat: Add pause/resume functionality to time tracking
Add pausedAt and pausedDuration columns to time_entries table.
New pause/resume endpoints with audit logging. Duration calculations
now correctly exclude paused time across start, stop, auto-stop,
and edit flows.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 07:15:57 +01:00
richardtekula
d26e537244 fix: Harden security - CORS, XSS, file uploads, error handling
- Restrict no-origin CORS bypass to development only
- Activate xss-clean middleware for input sanitization
- Add MIME type whitelist and filename sanitization to file uploads
- Reduce project upload limit from 50MB to 20MB
- Stop leaking stack traces in error responses

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:21:44 +01:00
richardtekula
929d0b461f fix: Allow project team members to update projects, handle empty companyId
- Relax project PATCH route from requireAdmin to checkProjectAccess
- Normalize empty string companyId to null in updateProject service to prevent UUID parse error

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:41:36 +01:00
richardtekula
dd15be93a9 feat: Add refresh token endpoint and remember me support
- Add POST /auth/refresh endpoint for token renewal
- Only set refresh token cookie when rememberMe is true
- Add rememberMe field to login validator schema

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 07:21:58 +01:00
richardtekula
d85f6761cf fix validator in create cpompany schema 2026-01-23 06:28:56 +01:00
richardtekula
4c4c9accae fix: Add pricingTiers to service Zod validators
- pricingTiers field was missing from createServiceSchema
- pricingTiers field was missing from updateServiceSchema
- This caused the field to be stripped during validation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 11:40:48 +01:00
richardtekula
5dde025855 fix: Services pricing tiers and timesheet naming
- Add pricingTiers field handling in createService/updateService
- Fix timesheet filename to use firstName-lastName-vykazprace-YYYY-MM.xlsx
- Fix company timesheet filename format similarly
- Removed timestamp from filename for cleaner naming

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 11:30:17 +01:00
richardtekula
5ade261cb2 fix: Timesheet naming and todo auto-assign fixes
- Fix timesheet filename to use firstName-lastName format with username fallback
- Remove auto-assign creator to todos (user must manually select assignees)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 11:20:10 +01:00
richardtekula
e5a88c36a9 Merge branch 'hotfix/part2' into hotfix/final 2026-01-22 08:00:47 +01:00
richardtekula
284d905d18 feat: Add notes search endpoint for enhanced global search
- Add searchNotes service function with company/project info
- Add /notes/search endpoint for searching notes content
- Returns matching notes with linked company/project names

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 07:49:10 +01:00
richardtekula
a0a6656a49 feat: Hotfix Part1 - Backend support for company postal code, service tiers, timesheet naming
- Add postal_code column to companies table
- Add pricing_tiers column to services table for tiered pricing
- Update timesheet upload to generate filename in format {firstname}-{lastname}-timesheet-{date}

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 07:46:50 +01:00
richardtekula
826fd467bc feat: Add farba field and company details to AI Kurzy module
- Add farba (color) field to kurzy schema and Zod validation
- Add company detail fields (firma_ico, firma_dic, firma_ic_dph, firma_sidlo) to ucastnici
- Remove console logs from ai-kurzy service
- Add SQL migration scripts for schema updates and data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 14:27:03 +01:00
richardtekula
4089bb4be2 feat: AI Kurzy module, project/service documents, services SQL import
- Add AI Kurzy module with courses, participants, and registrations management
- Add project documents and service documents features
- Add service folders for document organization
- Add SQL import queries for services from firmy.slovensko.ai
- Update todo notifications and group messaging
- Various API improvements and bug fixes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 11:32:49 +01:00
richardtekula
d9f16ad0a6 feat: Group chat and push notifications
- Add group chat tables (chat_groups, chat_group_members, group_messages)
- Add push subscriptions table for web push notifications
- Add group service, controller, routes
- Add push service, controller, routes
- Integrate push notifications with todos, messages, group messages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 07:27:13 +01:00
richardtekula
73a3c6bf95 hotfix: Security, performance, and code cleanup
- Remove hardcoded database password fallback
- Add encryption salt validation (min 32 chars)
- Separate EMAIL_ENCRYPTION_KEY from JWT_SECRET
- Fix command injection in status.service.js (use execFileSync)
- Remove unnecessary SQL injection regex middleware
- Create shared utilities (queryBuilder, pagination, emailAccountHelper)
- Fix N+1 query problems in contact and todo services
- Merge duplicate JMAP config functions
- Add database indexes migration
- Standardize error responses with error codes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 07:17:23 +01:00
richardtekula
0523087961 feat: Add email signature feature
- Add email_signatures table to schema
- Add email signature service, controller, routes
- Users can create/edit signature in Profile
- Toggle to include signature when sending email replies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 19:11:51 +01:00
richardtekula
514b6c8a92 feat: Add services, company documents, company timesheet export
- Add services table and CRUD endpoints (/api/services)
- Add company documents upload/download functionality
- Add company timesheet XLSX export endpoint
- Remove admin requirement from event routes (all authenticated users can manage events)
- Add service validators

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 18:45:01 +01:00
richardtekula
b542d1d635 fix: Remove phone from required fields in contact controller
Phone was incorrectly required in the controller validation
even though schema and database allow null.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 10:31:43 +01:00
richardtekula
d13442a979 fix: Accept null for all optional contact fields
lastName and secondaryEmail schemas now accept null values
sent from frontend, matching other optional fields pattern.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 10:20:50 +01:00
richardtekula
c1657ac37b fix: Allow empty string for phone in contact validation
The Zod schema was rejecting empty strings sent from the frontend.
Changed from z.string().optional().nullable() to z.union pattern
to properly handle "", null, and undefined values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 10:07:46 +01:00
richardtekula
47b68e672b feat: Member permissions, optional phone, public users endpoint
- Allow members to create todos, companies, projects
- Auto-assign creator to resources (companyUsers, projectUsers, todoUsers)
- Add public /api/users endpoint for all authenticated users
- Make phone field optional in personal contacts (schema + validation)
- Update todo routes to use checkTodoAccess for updates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 07:08:42 +01:00
richardtekula
3e8cd7b6ce fix: Add description field to personal contacts
- Add description to Zod validation schema
- Add description to controller normalizePayload function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 10:34:35 +01:00
richardtekula
2a9377ce3d feat: Add internal chat system and network access support
- Add messages table schema with soft delete support
- Add message service, controller and routes
- Update CORS to allow local network IPs
- Update server to listen on 0.0.0.0
- Fix cookie sameSite for local network development

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 10:13:14 +01:00
richardtekula
70fa080455 feat: Add user management APIs, status enum, enhanced notifications
- Add updateUser and resetUserPassword admin endpoints
- Change company status from boolean to enum (registered, lead, customer, inactive)
- Add 'important' event type to calendar validators and email templates
- Add 1-hour-before event notifications cron job
- Add 18:00 evening notifications for next-day events
- Add contact description field support
- Fix count() function usage in admin service
- Add SQL migrations for schema changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 09:41:29 +01:00
richardtekula
5d01fc9542 add license.txt 2025-12-29 09:02:24 +01:00
richardtekula
794d300746 add test to gitignore & jest settings 2025-12-17 10:54:59 +01:00
richardtekula
3cd2531f6b fix: Improve logging - fix LOG_LEVEL filter, reduce HTTP noise
- Fix LOG_LEVEL filtering logic (was inverted)
- HTTP logs now only show errors (4xx, 5xx) by default
- Add database connection check at startup
- Cron jobs logged on separate lines
- LOG_LEVEL=debug shows all HTTP requests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 09:54:07 +01:00
richardtekula
095a3a5b03 refactor: Clean up cron initialization logs
Single summary line instead of verbose duplicates:
[INFO] Cron jobs initialized: Calendar (07:00), Audit cleanup (00:00)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 09:50:03 +01:00