一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
19 行
1.1 KiB
TypeScript
19 行
1.1 KiB
TypeScript
import defaultAction from '../utils/defaultAction';
|
|
import { ModelType } from '../../../BaseModel';
|
|
import { Request, RequestMethod } from '../Api';
|
|
import { ErrorForbidden } from '../utils/errors';
|
|
import isNoteLockEnabled from '../../noteLock/isNoteLockEnabled';
|
|
import Revision from '../../../models/Revision';
|
|
|
|
export default async function(request: Request, id: string = null, link: string = null) {
|
|
// A revision is a JSON diff rather than a note body, so it cannot be served through a gated
|
|
// load. Reading or changing a locked revision is refused outright; deletion is left open, as
|
|
// it is for the note itself.
|
|
if (isNoteLockEnabled() && id && (request.method === RequestMethod.GET || request.method === RequestMethod.PUT)) {
|
|
const revision = await Revision.load(id, { fields: ['is_locked'] });
|
|
if (revision && revision.is_locked) throw new ErrorForbidden('A locked revision cannot be accessed through the API');
|
|
}
|
|
const whereQuery = isNoteLockEnabled() ? { sql: 'is_locked = 0' } : null;
|
|
return defaultAction(ModelType.Revision, request, id, link, ['id'], whereQuery);
|
|
}
|