mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Pad: Rename author
context properties to authorId
This commit is contained in:
parent
65bd5ffa6b
commit
aec512d1fa
3 changed files with 25 additions and 6 deletions
|
@ -57,6 +57,8 @@
|
||||||
* The `client` context property for the `handleMessageSecurity` and
|
* The `client` context property for the `handleMessageSecurity` and
|
||||||
`handleMessage` server-side hooks is deprecated; use the `socket` context
|
`handleMessage` server-side hooks is deprecated; use the `socket` context
|
||||||
property instead.
|
property instead.
|
||||||
|
* The `author` context property for the `padCreate` and `padUpdate` server-side
|
||||||
|
hooks is deprecated; use the new `authorId` context property instead.
|
||||||
* Returning `true` from a `handleMessageSecurity` hook function is deprecated;
|
* Returning `true` from a `handleMessageSecurity` hook function is deprecated;
|
||||||
return `'permitOnce'` instead.
|
return `'permitOnce'` instead.
|
||||||
* Changes to the `src/static/js/Changeset.js` library:
|
* Changes to the `src/static/js/Changeset.js` library:
|
||||||
|
|
|
@ -213,7 +213,8 @@ Called when a new pad is created.
|
||||||
Context properties:
|
Context properties:
|
||||||
|
|
||||||
* `pad`: The Pad object.
|
* `pad`: The Pad object.
|
||||||
* `author`: The ID of the author who created the pad.
|
* `authorId`: The ID of the author who created the pad.
|
||||||
|
* `author` (**deprecated**): Synonym of `authorId`.
|
||||||
|
|
||||||
## `padLoad`
|
## `padLoad`
|
||||||
|
|
||||||
|
@ -234,7 +235,8 @@ Called when an existing pad is updated.
|
||||||
Context properties:
|
Context properties:
|
||||||
|
|
||||||
* `pad`: The Pad object.
|
* `pad`: The Pad object.
|
||||||
* `author`: The ID of the author who updated the pad.
|
* `authorId`: The ID of the author who updated the pad.
|
||||||
|
* `author` (**deprecated**): Synonym of `authorId`.
|
||||||
* `revs`: The index of the new revision.
|
* `revs`: The index of the new revision.
|
||||||
* `changeset`: The changeset of this revision (see [Changeset
|
* `changeset`: The changeset of this revision (see [Changeset
|
||||||
Library](#index_changeset_library)).
|
Library](#index_changeset_library)).
|
||||||
|
|
|
@ -18,6 +18,7 @@ const CustomError = require('../utils/customError');
|
||||||
const readOnlyManager = require('./ReadOnlyManager');
|
const readOnlyManager = require('./ReadOnlyManager');
|
||||||
const randomString = require('../utils/randomstring');
|
const randomString = require('../utils/randomstring');
|
||||||
const hooks = require('../../static/js/pluginfw/hooks');
|
const hooks = require('../../static/js/pluginfw/hooks');
|
||||||
|
const {padutils: {warnDeprecated}} = require('../../static/js/pad_utils');
|
||||||
const promises = require('../utils/promises');
|
const promises = require('../utils/promises');
|
||||||
|
|
||||||
// serialization/deserialization attributes
|
// serialization/deserialization attributes
|
||||||
|
@ -109,11 +110,25 @@ Pad.prototype.appendRevision = async function (aChangeset, authorId) {
|
||||||
// set the author to pad
|
// set the author to pad
|
||||||
if (authorId) p.push(authorManager.addPad(authorId, this.id));
|
if (authorId) p.push(authorManager.addPad(authorId, this.id));
|
||||||
|
|
||||||
if (this.head === 0) {
|
let hook = 'padCreate';
|
||||||
hooks.callAll('padCreate', {pad: this, author: authorId});
|
const context = {
|
||||||
} else {
|
pad: this,
|
||||||
hooks.callAll('padUpdate', {pad: this, author: authorId, revs: newRev, changeset: aChangeset});
|
authorId,
|
||||||
|
get author() {
|
||||||
|
warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
|
||||||
|
return this.authorId;
|
||||||
|
},
|
||||||
|
set author(authorId) {
|
||||||
|
warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
|
||||||
|
this.authorId = authorId;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (this.head !== 0) {
|
||||||
|
hook = 'padUpdate';
|
||||||
|
context.revs = newRev;
|
||||||
|
context.changeset = aChangeset;
|
||||||
}
|
}
|
||||||
|
hooks.callAll(hook, context);
|
||||||
|
|
||||||
await Promise.all(p);
|
await Promise.all(p);
|
||||||
return newRev;
|
return newRev;
|
||||||
|
|
Loading…
Reference in a new issue