Add alert creation on note sharing - triggers alerts for shared_with users
This commit is contained in:
+21
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user