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
+21
View File
@@ -2794,6 +2794,27 @@
}
const noteRecord = await pb.collection(NOTES_COLLECTION).create(payload);
// Create alerts for each shared_with user
if (selectedUsers.length > 0) {
console.log(`📢 Creating alerts for ${selectedUsers.length} users...`);
for (const user of selectedUsers) {
try {
const alertRecord = await pb.collection('Alerts').create({
note_id: noteRecord.id,
note_title: noteTitle || '(untitled)',
shared_name: user.name,
created_by: displayNameCache,
created_at: new Date().toISOString(),
read: false,
});
console.log(`✓ Alert created for ${user.name}:`, alertRecord.id);
} catch (alertErr) {
console.error(`Error creating alert for ${user.name}:`, alertErr);
}
}
}
const attachmentRecords = [];
let audioAttachmentCount = 0;
let fileAttachmentCount = 0;