Add alert creation on note sharing - triggers alerts for shared_with users

This commit is contained in:
2026-01-16 01:29:48 +00:00
parent 9ced9fd4ed
commit 7c4459fd47
3 changed files with 81 additions and 4 deletions
+40
View File
@@ -167,4 +167,44 @@ Project history, decisions, and architectural milestones
becomes more established and needs full file separation
- Status: Functional and ready for independent container updates
[2026-01-15 INVESTIGATION] PocketBase Associations Collection API Rules
- Problem: User email lookup queries Associations → "only superusers can perform this action"
- Root Cause: Associations collection LIST API rule is restricted (default deny all)
- Solution: Set Associations LIST API rule to `@request.auth.id != ""` (allow authenticated users)
- Forum Source: https://github.com/pocketbase/pocketbase/discussions/5948#5948-answer
* Official pattern for "authenticate first" checks
* Works for all read/write operations
* Syntax: `@request.auth.id != ""` (empty string = anonymous/unauthenticated)
- Implementation (Manual in PocketBase Admin):
1. Go to PocketBase Admin Console
2. Select Associations collection
3. API Rules tab → List action
4. Set rule to: `@request.auth.id != ""`
5. Save and test with authenticated user
- Why UserAlertSystem Works: Unknown at this point (may have different API rule set)
- Status: Solution identified, requires manual PocketBase admin console update
[2026-01-16 FEATURE] Note Creation Alerts - Notify Shared Users
- Problem: When a note is created and shared with users, those users should receive alerts
- Solution Implemented:
* When note is created with `shared_with` array
* Loop through each user in `shared_with`
* Create alert record in Alerts collection for each user
* Alert includes: note_id, note_title, shared_name, created_by, created_at, read flag
- Code Location: index.html ~line 2800 (in submitNote function, after noteRecord creation)
- Logic Flow:
1. Note created with `shared_with: selectedUsers.map(u => u.name)`
2. For each user in selectedUsers:
- Create Alerts record with note metadata
- Log alert creation for debugging
3. Alert system monitors Alerts collection for new records
4. Alert triggers notification/sound when created
- PocketBase Requirements:
* Alerts collection must exist with proper API rules
* Fields: note_id (relation to Notes), note_title (text), shared_name (text),
created_by (text), created_at (datetime), read (boolean)
* LIST API rule should allow authenticated users to read
- Status: Implementation complete in index.html, ready to test once Alerts collection is verified
================================================================================