Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3518317
D13732.id45232.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13732.id45232.diff
View Options
diff --git a/keyserver/src/cron/cron.js b/keyserver/src/cron/cron.js
--- a/keyserver/src/cron/cron.js
+++ b/keyserver/src/cron/cron.js
@@ -13,6 +13,7 @@
import { deleteExpiredCookies } from '../deleters/cookie-deleters.js';
import { deleteOrphanedDays } from '../deleters/day-deleters.js';
import { deleteOrphanedEntries } from '../deleters/entry-deleters.js';
+import { deleteOrphanedInviteLinks } from '../deleters/link-deleters.js';
import { deleteOrphanedMemberships } from '../deleters/membership-deleters.js';
import { deleteOrphanedMessages } from '../deleters/message-deleters.js';
import { deleteOrphanedNotifs } from '../deleters/notif-deleters.js';
@@ -72,6 +73,7 @@
await deleteExpiredUpdates();
await deleteUnassignedUploads();
await deleteStaleSIWENonceEntries();
+ await deleteOrphanedInviteLinks();
} catch (e) {
console.warn('encountered error while trying to clean database', e);
}
diff --git a/keyserver/src/deleters/link-deleters.js b/keyserver/src/deleters/link-deleters.js
--- a/keyserver/src/deleters/link-deleters.js
+++ b/keyserver/src/deleters/link-deleters.js
@@ -65,4 +65,20 @@
await deleteInviteLinks([result]);
}
-export { deleteInviteLink };
+async function deleteOrphanedInviteLinks(): Promise<void> {
+ const [selectResults] = await dbQuery(SQL`
+ SELECT i.id, i.name, i.blob_holder AS blobHolder
+ FROM invite_links i
+ LEFT JOIN threads tc ON tc.id = i.community
+ LEFT JOIN threads tt ON tt.id = i.thread
+ WHERE tc.id IS NULL OR (i.thread IS NOT NULL AND tt.id IS NULL)
+ `);
+ const inviteLinksToDelete = selectResults.map(({ id, name, blobHolder }) => ({
+ id,
+ name,
+ blobHolder,
+ }));
+ await deleteInviteLinks(inviteLinksToDelete);
+}
+
+export { deleteInviteLink, deleteOrphanedInviteLinks };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 7:43 PM (19 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2696080
Default Alt Text
D13732.id45232.diff (1 KB)
Attached To
Mode
D13732: [keyserver] Add cron to delete orphaned invite links
Attached
Detach File
Event Timeline
Log In to Comment