diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a00c1534..9657139c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,9 @@ #### For plugin authors * New `expressPreSession` server-side hook. -* New `padDefaultContent` server-side hook. +* Pad server-side hook changes: + * `padCopy`: New `srcPad` context property. + * `padDefaultContent`: New hook. * The `db` property on Pad objects is now public. * New `getAuthorId` server-side hook. * New APIs for processing attributes: `ep_etherpad-lite/static/js/attributes` @@ -65,8 +67,13 @@ * The `client` context property for the `handleMessageSecurity` and `handleMessage` server-side hooks is deprecated; use the `socket` context property instead. -* The `author` context property for the `padCreate` and `padUpdate` server-side - hooks is deprecated; use the new `authorId` context property instead. +* Pad server-side hook changes: + * `padCopy`: The `originalPad` context property is deprecated; use `srcPad` + instead. + * `padCreate`: The `author` context property is deprecated; use the new + `authorId` context property instead. + * `padUpdate`: The `author` context property is deprecated; use the new + `authorId` context property instead. * Returning `true` from a `handleMessageSecurity` hook function is deprecated; return `'permitOnce'` instead. * Changes to the `src/static/js/Changeset.js` library: diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 52a99baf2..b2b0da8b6 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -344,7 +344,7 @@ Order of events when a pad is copied: Context properties: - * `originalPad`: The source Pad object. + * `srcPad`: The source Pad object. * `destinationID`: The ID of the pad copied from `originalPad`. Usage examples: diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index a5ecf2d71..a029db53d 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -429,7 +429,14 @@ Pad.prototype.copy = async function (destinationID, force) { await padManager.getPad(destinationID, null); // let the plugins know the pad was copied - await hooks.aCallAll('padCopy', {originalPad: this, destinationID}); + await hooks.aCallAll('padCopy', { + get originalPad() { + warnDeprecated('padCopy originalPad context property is deprecated; use srcPad instead'); + return this.srcPad; + }, + srcPad: this, + destinationID, + }); return {padID: destinationID}; }; @@ -518,7 +525,14 @@ Pad.prototype.copyPadWithoutHistory = async function (destinationID, force, auth const changeset = Changeset.pack(oldLength, newLength, assem.toString(), newText); newPad.appendRevision(changeset, authorId); - await hooks.aCallAll('padCopy', {originalPad: this, destinationID}); + await hooks.aCallAll('padCopy', { + get originalPad() { + warnDeprecated('padCopy originalPad context property is deprecated; use srcPad instead'); + return this.srcPad; + }, + srcPad: this, + destinationID, + }); return {padID: destinationID}; };