Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3518529
D13731.id45233.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
D13731.id45233.diff
View Options
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
@@ -10,6 +10,37 @@
import { deleteBlob } from '../services/blob.js';
import { Viewer } from '../session/viewer.js';
+type InviteLinksToDelete = {
+ +id: string,
+ +name: string,
+ +blobHolder: string,
+};
+async function deleteInviteLinks(
+ links: $ReadOnlyArray<InviteLinksToDelete>,
+): Promise<void> {
+ await Promise.all(
+ links.map(({ name, blobHolder }) =>
+ deleteBlob(
+ {
+ hash: inviteLinkBlobHash(name),
+ holder: blobHolder,
+ },
+ true,
+ ),
+ ),
+ );
+ const ids = links.map(({ id }) => id);
+ await dbQuery(
+ SQL`
+ START TRANSACTION;
+ DELETE FROM invite_links WHERE id IN (${ids});
+ DELETE FROM ids WHERE id IN (${ids});
+ COMMIT;
+ `,
+ { multipleStatements: true },
+ );
+}
+
async function deleteInviteLink(
viewer: Viewer,
request: DisableInviteLinkRequest,
@@ -23,22 +54,15 @@
throw new ServerError('invalid_credentials');
}
- const query = SQL`
- DELETE FROM invite_links
+ const [[result]] = await dbQuery(SQL`
+ SELECT id, name, blob_holder AS blobHolder
+ FROM invite_links
WHERE name = ${request.name} AND community = ${request.communityID}
- RETURNING blob_holder AS blobHolder
- `;
-
- const [[row]] = await dbQuery(query);
- if (row?.blobHolder) {
- await deleteBlob(
- {
- hash: inviteLinkBlobHash(request.name),
- holder: row.blobHolder,
- },
- true,
- );
+ `);
+ if (!result) {
+ return;
}
+ await deleteInviteLinks([result]);
}
export { deleteInviteLink };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 8:11 PM (19 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2696206
Default Alt Text
D13731.id45233.diff (1 KB)
Attached To
Mode
D13731: [keyserver] Also delete from ids table when deleting invite links
Attached
Detach File
Event Timeline
Log In to Comment