> When attachmentId is used, the attachment should not automatically be deleted, because the client user claims responsibility for maintaining the attachment.
I don't think that this is an obvious assumption.
If that is something specific you need for the blocklist, we could add a flag to disable pruning explicitly.
Otherwise, the algorithm is pretty straightforward:
```
const allRecords = await client.db.list();
const currentRecordsIDs = new Set(allRecords.map(r => r.id));
const allAttachments = await client.attachments.listAll();
const attachmentsToDelete = allAttachments.reduce((entry, acc) => {
if (!currentRecordsIDs.has(entry.attachmentId)) {
acc.push(id);
return acc;
}
}, []);
await client.attachments.deleteAll(attachmentsToDelete);
```
I propose that we execute this on the 24H timer, and not on push notifications.
Bug 1763626 Comment 3 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
> When attachmentId is used, the attachment should not automatically be deleted, because the client user claims responsibility for maintaining the attachment.
I don't think that this is an obvious assumption.
If that is something specific you need for the blocklist, we could add a flag to disable pruning explicitly.
Otherwise, the algorithm is pretty straightforward:
```
const allRecords = await client.db.list();
const currentRecordsIDs = new Set(allRecords.map(r => r.id));
const allAttachments = await client.attachments.listAll();
const attachmentsToDelete = allAttachments.reduce((entry, acc) => {
if (!currentRecordsIDs.has(entry.record.id)) {
acc.push(entry.attachmentId);
return acc;
}
}, []);
await client.attachments.deleteAll(attachmentsToDelete);
```
I propose that we execute this on the 24H timer, and not on push notifications.