Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/checkPad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const performCheck = async () => {
await db.init();
console.log("Checking if " + padId + " exists")
const padManager = require('ep_etherpad-lite/node/db/PadManager');
if (!await padManager.doesPadExists(padId)) throw new Error('Pad does not exist');
if (!(await padManager.doesPadExists(padId))) throw new Error('Pad does not exist');
const pad = await padManager.getPad(padId);
await pad.check();
console.log('Finished checking pad.');
Expand Down
279 changes: 137 additions & 142 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/node/db/GroupManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports.deleteGroup = async (groupID: string): Promise<void> => {

// Delete associated sessions in parallel. This should be done before deleting the group2sessions
// record because deleting a session updates the group2sessions record.
const {sessionIDs = {}} = await db.get(`group2sessions:${groupID}`) || {};
const {sessionIDs = {}} = (await db.get(`group2sessions:${groupID}`)) || {};
await Promise.all(Object.keys(sessionIDs).map(async (sessionId) => {
await sessionManager.deleteSession(sessionId);
}));
Expand Down Expand Up @@ -113,7 +113,7 @@ exports.createGroupIfNotExistsFor = async (groupMapper: string|object) => {
throw new CustomError('groupMapper is not a string', 'apierror');
}
const groupID = await db.get(`mapper2group:${groupMapper}`);
if (groupID && await exports.doesGroupExist(groupID)) return {groupID};
if (groupID && (await exports.doesGroupExist(groupID))) return {groupID};
const result = await exports.createGroup();
await Promise.all([
db.set(`mapper2group:${groupMapper}`, result.groupID),
Expand Down
8 changes: 4 additions & 4 deletions src/node/db/Pad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class Pad {
meta: {
author: authorId,
timestamp: Date.now(),
...newRev === this.getKeyRevisionNumber(newRev) ? {
...(newRev === this.getKeyRevisionNumber(newRev) ? {
pool: this.pool,
atext: this.atext,
} : {},
} : {}),
},
}),
this.saveToDatabase(),
Expand All @@ -135,10 +135,10 @@ class Pad {
pad_utils.warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
this.authorId = authorId;
},
...this.head === 0 ? {} : {
...(this.head === 0 ? {} : {
revs: newRev,
changeset: aChangeset,
},
}),
}),
]);
return newRev;
Expand Down
4 changes: 2 additions & 2 deletions src/node/db/PadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const globalPads:MapArrayType<any> = {
*
* Updated without db access as new pads are created/old ones removed.
*/
const padList = new class {
const padList = new (class {
private _cachedList: string[] | null;
private _list: Set<string>;
private _loaded: Promise<void> | null;
Expand Down Expand Up @@ -95,7 +95,7 @@ const padList = new class {
this._list.delete(name);
this._cachedList = null;
}
}();
})();

// initialises the all-knowing data structure

Expand Down
2 changes: 1 addition & 1 deletion src/node/db/SecurityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ exports.checkAccess = async (padID:string, sessionCookie:string, token:string, u

const grant = {
accessStatus: 'grant',
authorID: sessionAuthorID || await authorManager.getAuthorId(token, userSettings),
authorID: sessionAuthorID || (await authorManager.getAuthorId(token, userSettings)),
};

if (!padID.includes('$')) {
Expand Down
4 changes: 2 additions & 2 deletions src/node/handler/PadMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ exports.handleMessage = async (socket:any, message: ClientVarMessage) => {
`IP:${settings.disableIPlogging ? 'ANONYMOUS' : socket.request.ip}`,
`originalAuthorID:${thisSession.author}`,
`newAuthorID:${authorID}`,
...(user && user.username) ? [`username:${user.username}`] : [],
...((user && user.username) ? [`username:${user.username}`] : []),
`message:${message}`,
].join(' '));
}
Expand Down Expand Up @@ -1097,7 +1097,7 @@ const handleClientReady = async (socket:any, message: ClientReadyMessage) => {
if (authorId == null) return;

// reuse previously created cache of author's data
const authorInfo = historicalAuthorData[authorId] || await authorManager.getAuthor(authorId);
const authorInfo = historicalAuthorData[authorId] || (await authorManager.getAuthor(authorId));
if (authorInfo == null) {
messageLogger.error(
`Author ${authorId} connected via socket.io session ${roomSocket.id} is missing from ` +
Expand Down
4 changes: 2 additions & 2 deletions src/node/security/SecretRotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class SecretRotator {
// TODO: This is racy. If two instances start up at the same time and there are no existing
// matching publications, each will generate and publish their own paramters. In practice this
// is unlikely to happen, and if it does it can be fixed by restarting both Etherpad instances.
const dbKeys:string[] = await db.findKeys(`${this._dbPrefix}:*`, null) || [];
const dbKeys:string[] = (await db.findKeys(`${this._dbPrefix}:*`, null)) || [];
let currentParams:any = null;
let currentId = null;
const dbWrites:any[] = [];
Expand Down Expand Up @@ -245,7 +245,7 @@ export class SecretRotator {
// The secrets derived from currentParams MUST be the first secrets.
const secrets = await this._deriveSecrets(currentParams, now);
await Promise.all(
allParams.map(async (p) => secrets.push(...await this._deriveSecrets(p, now))));
allParams.map(async (p) => secrets.push(...(await this._deriveSecrets(p, now)))));
// Update this.secrets all at once to avoid race conditions.
this.secrets.length = 0;
this.secrets.push(...secrets);
Expand Down
4 changes: 2 additions & 2 deletions src/node/utils/Cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const createRevision = async (aChangeset: AChangeSet, timestamp: number, isKeyRe
meta: {
author: authorId,
timestamp: timestamp,
...isKeyRev ? {
...(isKeyRev ? {
pool: pool,
atext: atext,
} : {},
} : {}),
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/node/utils/ImportEtherpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports.setPadRaw = async (padId: string, r: string, authorId = '') => {
// DB key prefixes for pad records. Each key is expected to have the form `${prefix}:${padId}` or
// `${prefix}:${padId}:${otherstuff}`.
const padKeyPrefixes = [
...await hooks.aCallAll('exportEtherpadAdditionalContent'),
...(await hooks.aCallAll('exportEtherpadAdditionalContent')),
'pad',
];

Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"cross-spawn": "^7.0.6",
"ejs": "^3.1.10",
"esbuild": "^0.25.2",
"express": "4.21.2",
"express": "5.1.0",
"express-rate-limit": "^7.5.0",
"fast-deep-equal": "^3.1.3",
"find-root": "1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/static/js/ace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ const Ace2Editor = function () {

let actionsPendingInit = [];

const pendingInit = (func) => function (...args) {
const pendingInit = (func) => (function(...args) {
const action = () => func.apply(this, args);
if (loaded) return action();
actionsPendingInit.push(action);
};
});

const doActionsPendingInit = () => {
for (const fn of actionsPendingInit) fn();
Expand Down
2 changes: 1 addition & 1 deletion src/static/js/ace2_inner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2554,7 +2554,7 @@ function Ace2Inner(editorInfo, cssManagers) {
let stopped = false;

inCallStackIfNecessary('handleKeyEvent', function () {
if (type === 'keypress' || (isTypeForSpecialKey && keyCode === 13 /* return*/)) {
if (type === 'keypress' || ((isTypeForSpecialKey && keyCode === 13) /* return*/)) {
// in IE, special keys don't send keypress, the keydown does the action
if (!outsideKeyPress(evt)) {
evt.preventDefault();
Expand Down
8 changes: 4 additions & 4 deletions src/static/js/collab_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
});
};

const serverMessageTaskQueue = new class {
const serverMessageTaskQueue = new (class {
constructor() {
this._promiseChain = Promise.resolve();
}
Expand All @@ -178,7 +178,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
// fn() throws/rejects (due to the .catch() added above).
return await taskPromise;
}
}();
})();

const handleMessageFromServer = (evt) => {
if (!getSocket()) return;
Expand Down Expand Up @@ -371,7 +371,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
// is connected for the first time.
let deferredActions = [];

const defer = (func, tag) => function (...args) {
const defer = (func, tag) => (function(...args) {
const action = () => {
func.call(this, ...args);
};
Expand All @@ -381,7 +381,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
} else {
action();
}
};
});

const doDeferredActions = (tag) => {
const newArray = [];
Expand Down
4 changes: 2 additions & 2 deletions src/static/js/pad_cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import {Cookies} from "./pad_utils";

exports.padcookie = new class {
exports.padcookie = new (class {
constructor() {
this.cookieName_ = window.location.protocol === 'https:' ? 'prefs' : 'prefsHttp';
}
Expand Down Expand Up @@ -68,4 +68,4 @@ exports.padcookie = new class {
clear() {
this.writePrefs_({});
}
}();
})();
4 changes: 2 additions & 2 deletions src/static/js/pad_editbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const syncAnimation = (() => {
};
})();

exports.padeditbar = new class {
exports.padeditbar = new (class {
constructor() {
this._editbarPosition = 0;
this.commands = {};
Expand Down Expand Up @@ -479,4 +479,4 @@ exports.padeditbar = new class {
}
});
}
}();
})();
4 changes: 1 addition & 3 deletions src/static/js/vendors/jquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,7 @@

// Support: IE 9 - 11+
// IE doesn't have `contains` on SVG.
a.contains ?
a.contains( bup ) :
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
(a.contains ? a.contains( bup ) : a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16)
) );
};

Expand Down
2 changes: 1 addition & 1 deletion src/tests/backend/specs/ExportEtherpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe(__filename, function () {

beforeEach(async function () {
padId = common.randomString();
assert(!await padManager.doesPadExist(padId));
assert(!(await padManager.doesPadExist(padId)));
});

describe('exportEtherpadAdditionalContent', function () {
Expand Down
14 changes: 7 additions & 7 deletions src/tests/backend/specs/ImportEtherpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe(__filename, function () {

beforeEach(async function () {
padId = randomString(10);
assert(!await padManager.doesPadExist(padId));
assert(!(await padManager.doesPadExist(padId)));
});

it('unknown db records are ignored', async function () {
Expand All @@ -62,7 +62,7 @@ describe(__filename, function () {
[badKey]: 'value',
...makeExport(makeAuthorId()),
}));
assert(await db.get(badKey) == null);
assert((await db.get(badKey)) == null);
});

it('changes are all or nothing', async function () {
Expand All @@ -71,8 +71,8 @@ describe(__filename, function () {
data['pad:differentPadId:revs:0'] = data['pad:testing:revs:0'];
delete data['pad:testing:revs:0'];
assert.rejects(importEtherpad.setPadRaw(padId, JSON.stringify(data)), /unexpected pad ID/);
assert(!await authorManager.doesAuthorExist(authorId));
assert(!await padManager.doesPadExist(padId));
assert(!(await authorManager.doesAuthorExist(authorId)));
assert(!(await padManager.doesPadExist(padId)));
});

describe('author pad IDs', function () {
Expand All @@ -85,7 +85,7 @@ describe(__filename, function () {
assert.deepEqual((await authorManager.listPadsOfAuthor(existingAuthorId)).padIDs, []);
newAuthorId = makeAuthorId();
assert.notEqual(newAuthorId, existingAuthorId);
assert(!await authorManager.doesAuthorExist(newAuthorId));
assert(!(await authorManager.doesAuthorExist(newAuthorId)));
});

it('author does not yet exist', async function () {
Expand Down Expand Up @@ -199,12 +199,12 @@ describe(__filename, function () {
...makeExport(makeAuthorId()),
'custom:testingx': 'x',
})), /unexpected pad ID/);
assert(await db.get(`custom:${padId}x`) == null);
assert((await db.get(`custom:${padId}x`)) == null);
await assert.rejects(importEtherpad.setPadRaw(padId, JSON.stringify({
...makeExport(makeAuthorId()),
'custom:testingx:foo': 'x',
})), /unexpected pad ID/);
assert(await db.get(`custom:${padId}x:foo`) == null);
assert((await db.get(`custom:${padId}x:foo`)) == null);
});
});
});
18 changes: 9 additions & 9 deletions src/tests/backend/specs/SessionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe(__filename, function () {
describe('set', function () {
it('set of null is a no-op', async function () {
await set(null);
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('set of non-expiring session', async function () {
Expand All @@ -59,14 +59,14 @@ describe(__filename, function () {
assert.equal(JSON.stringify(await db.get(`sessionstorage:${sid}`)), JSON.stringify(sess));
await new Promise((resolve) => setTimeout(resolve, 110));
// Writing should start a timeout.
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('set of already expired session', async function () {
const sess:any = {foo: 'bar', cookie: {expires: new Date(1)}};
await set(sess);
// No record should have been created.
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('switch from non-expiring to expiring', async function () {
Expand All @@ -75,7 +75,7 @@ describe(__filename, function () {
const sess2:any = {foo: 'bar', cookie: {expires: new Date(Date.now() + 100)}};
await set(sess2);
await new Promise((resolve) => setTimeout(resolve, 110));
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('switch from expiring to non-expiring', async function () {
Expand All @@ -90,7 +90,7 @@ describe(__filename, function () {

describe('get', function () {
it('get of non-existent entry', async function () {
assert(await get() == null);
assert((await get()) == null);
});

it('set+get round trip', async function () {
Expand All @@ -111,14 +111,14 @@ describe(__filename, function () {
assert.equal(JSON.stringify(await get()), JSON.stringify(sess));
await new Promise((resolve) => setTimeout(resolve, 110));
// Reading should start a timeout.
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('get of record from previous run (already expired)', async function () {
const sess = {foo: 'bar', cookie: {expires: new Date(1)}};
await db.set(`sessionstorage:${sid}`, sess);
assert(await get() == null);
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await get()) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('external expiration update is picked up', async function () {
Expand Down Expand Up @@ -151,7 +151,7 @@ describe(__filename, function () {
const sess:any = {cookie: {expires: new Date(Date.now() + 100)}};
await set(sess);
await destroy();
assert(await db.get(`sessionstorage:${sid}`) == null);
assert((await db.get(`sessionstorage:${sid}`)) == null);
});

it('destroy cancels the timeout', async function () {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/backend/specs/api/sessionsAndGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe(__filename, function () {
.expect((res:any) => {
assert.equal(res.body.code, 0);
});
assert(await db.get(`mapper2group:${mapper}`) == null);
assert((await db.get(`mapper2group:${mapper}`)) == null);
});

// Test coverage for https://github.com/ether/etherpad-lite/issues/4227
Expand Down
Loading
Loading