mirror of
https://github.com/outline/outline.git
synced 2026-06-26 09:44:24 +03:00
12c71f267e
* Improve scoping of public share subscriptions
* fix: Add missing transaction, includeChildDocuments check, and test documentId
- Pass { transaction } to ShareSubscription.create in the subscribe handler
so the insert runs atomically with the duplicate-check findOne/lock
- Skip ancestor-scoped subscription notifications when the share has
includeChildDocuments=false, preventing notifications for inaccessible docs
- Add required documentId field to all share subscription tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: Resolve type error for nullable share.documentId in tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* JSDoc
* Hide subscription option for logged-in users
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
"use strict";
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
return queryInterface.sequelize.transaction(async (transaction) => {
|
|
// Remove all existing records as they lack document scope
|
|
await queryInterface.bulkDelete(
|
|
"share_subscriptions",
|
|
{},
|
|
{ transaction }
|
|
);
|
|
|
|
await queryInterface.addColumn(
|
|
"share_subscriptions",
|
|
"documentId",
|
|
{
|
|
type: Sequelize.UUID,
|
|
allowNull: false,
|
|
references: {
|
|
model: "documents",
|
|
key: "id",
|
|
},
|
|
onDelete: "CASCADE",
|
|
},
|
|
{ transaction }
|
|
);
|
|
|
|
// Replace old unique index with one that includes documentId
|
|
await queryInterface.removeIndex(
|
|
"share_subscriptions",
|
|
["shareId", "emailFingerprint"],
|
|
{ transaction }
|
|
);
|
|
|
|
await queryInterface.addIndex(
|
|
"share_subscriptions",
|
|
["shareId", "documentId", "emailFingerprint"],
|
|
{ unique: true, transaction }
|
|
);
|
|
});
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
return queryInterface.sequelize.transaction(async (transaction) => {
|
|
await queryInterface.removeIndex(
|
|
"share_subscriptions",
|
|
["shareId", "documentId", "emailFingerprint"],
|
|
{ transaction }
|
|
);
|
|
|
|
await queryInterface.addIndex(
|
|
"share_subscriptions",
|
|
["shareId", "emailFingerprint"],
|
|
{ unique: true, transaction }
|
|
);
|
|
|
|
await queryInterface.removeColumn("share_subscriptions", "documentId", {
|
|
transaction,
|
|
});
|
|
});
|
|
},
|
|
};
|