mirror of
https://github.com/outline/outline.git
synced 2026-12-01 01:14:11 +03:00
Follow-up fixes to the retention feature. The superseded CleanupDeletedDocumentsTask was still registered and ran hourly, hard deleting documents 30 days after `deletedAt` regardless of the team's configured period. Any retention longer than 30 days — including infinite — had no effect. The `destroyedAt` column was declared with a bare `@Column`. Decorator metadata is disabled in the server build, so sequelize-typescript could not infer its type and threw while loading the Document model. Documents pending permanent deletion stayed readable and restorable through `documents.info`, `documents.restore` and the MCP restore tool. They are now treated as if they no longer exist. Also: - Add trash and data retention controls to workspace security settings, the only way to configure either was to call the API directly. - Derive the retention tranches to process from the periods teams actually use, so a team holding a period that is no longer offered is not skipped. - Bound the trash expiry task by `limit`, it previously ran an unbounded UPDATE across the whole documents table every hour. - Match team preferences on JSON text rather than casting to int, so one bad value cannot fail the query for every other team in the batch. - Derive the API validation schema from the same presets the UI offers. - Send `ASC` rather than `asc` from the trash list, the sort direction was silently coerced back to descending. - Move the retention badge in with the other document badges, pluralize it, and never show a negative day count. - Drop the unused `Template.destroyedAt` computed, which returned a future date under a name meaning the opposite on the sibling model. - Rename the migration to match its position in the sequence and the column it adds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U3kXbDxLMJesYLM5E4P6HQ
128 lines
3.7 KiB
TypeScript
128 lines
3.7 KiB
TypeScript
import type {
|
|
RetentionPeriodPreset,
|
|
TeamPreferences,
|
|
UserPreferences,
|
|
} from "./types";
|
|
import {
|
|
TOCPosition,
|
|
TeamPreference,
|
|
UserPreference,
|
|
EmailDisplay,
|
|
CommentingAccess,
|
|
NotificationBadgeType,
|
|
} from "./types";
|
|
|
|
/** Allowed retention period values in days. 0 means infinite (never delete). */
|
|
export const RetentionPeriodPresets: readonly RetentionPeriodPreset[] = [
|
|
0, 7, 14, 30, 90, 180, 365,
|
|
];
|
|
|
|
/**
|
|
* Whether the given value is a retention period that can be configured.
|
|
*
|
|
* @param value the value to check.
|
|
* @returns true if the value is a supported retention period.
|
|
*/
|
|
export function isRetentionPeriodPreset(
|
|
value: unknown
|
|
): value is RetentionPeriodPreset {
|
|
return RetentionPeriodPresets.some((days) => days === value);
|
|
}
|
|
|
|
export const MAX_AVATAR_DISPLAY = 6;
|
|
|
|
/** Height of the app's fixed header in pixels. */
|
|
export const HEADER_HEIGHT = 56;
|
|
|
|
/** Preset colors offered when choosing an icon color. */
|
|
export const colorPalette = [
|
|
"#4E5C6E",
|
|
"#0366D6",
|
|
"#2BC2FF",
|
|
"#9E5CF7",
|
|
"#FF825C",
|
|
"#FF5C80",
|
|
"#FFBE0B",
|
|
"#42DED1",
|
|
"#00D084",
|
|
"#FF4DFA",
|
|
"#2F362F",
|
|
];
|
|
|
|
export const Pagination = {
|
|
defaultLimit: 25,
|
|
defaultOffset: 0,
|
|
maxLimit: 100,
|
|
sidebarLimit: 10,
|
|
};
|
|
|
|
export const CSRF = {
|
|
/** Cookie name used on secure origins. */
|
|
secureCookieName: "__Host-csrfToken",
|
|
/** Cookie name used over HTTP, where the `__Host-` prefix is not accepted. */
|
|
cookieName: "csrfToken",
|
|
/** Request header that carries the token for API requests. */
|
|
headerName: "x-csrf-token",
|
|
/** Hidden field that carries the token for native form submissions. */
|
|
fieldName: "_csrf",
|
|
};
|
|
|
|
/** The maximum number of sub-requests permitted in a single `/batch` request. */
|
|
export const BatchMaxRequests = 25;
|
|
|
|
/**
|
|
* RPC methods that may be coalesced into a single `/batch` request. Deliberately
|
|
* curated to simple JSON mutations — no reads, redirects, file responses, or
|
|
* endpoints that set response headers. Shared by the client (which collects
|
|
* these into a batch) and the server (which only dispatches allowlisted methods).
|
|
*
|
|
* When adding a method, also add its router to `dispatchableRouters` in
|
|
* server/routes/api/batch/batch.ts so the server can resolve its middleware.
|
|
*/
|
|
export const BatchableApiMethods = [
|
|
"documents.update",
|
|
"documents.move",
|
|
"documents.archive",
|
|
"documents.restore",
|
|
"documents.unpublish",
|
|
"documents.delete",
|
|
"collections.update",
|
|
"collections.move",
|
|
"collections.archive",
|
|
"collections.restore",
|
|
"collections.delete",
|
|
"stars.create",
|
|
"stars.delete",
|
|
"pins.create",
|
|
"pins.delete",
|
|
] as const;
|
|
|
|
export const TeamPreferenceDefaults: TeamPreferences = {
|
|
[TeamPreference.SeamlessEdit]: true,
|
|
[TeamPreference.ViewersCanExport]: true,
|
|
[TeamPreference.MembersCanInvite]: false,
|
|
[TeamPreference.MembersCanCreateApiKey]: true,
|
|
[TeamPreference.MembersCanDeleteAccount]: true,
|
|
[TeamPreference.PreviewsInEmails]: true,
|
|
[TeamPreference.PublicBranding]: false,
|
|
[TeamPreference.Commenting]: CommentingAccess.Members,
|
|
[TeamPreference.CustomTheme]: undefined,
|
|
[TeamPreference.TocPosition]: TOCPosition.Left,
|
|
[TeamPreference.PreventDocumentEmbedding]: false,
|
|
[TeamPreference.TrashRetentionDays]: 30,
|
|
[TeamPreference.DataRetentionDays]: 30,
|
|
[TeamPreference.EmailDisplay]: EmailDisplay.Members,
|
|
[TeamPreference.MCP]: true,
|
|
[TeamPreference.DisabledEmbeds]: [],
|
|
};
|
|
|
|
export const UserPreferenceDefaults: UserPreferences = {
|
|
[UserPreference.RememberLastPath]: true,
|
|
[UserPreference.UseCursorPointer]: true,
|
|
[UserPreference.CodeBlockLineNumers]: true,
|
|
[UserPreference.CommentsInGutter]: true,
|
|
[UserPreference.SortCommentsByOrderInDocument]: true,
|
|
[UserPreference.EnableSmartText]: true,
|
|
[UserPreference.NotificationBadge]: NotificationBadgeType.Count,
|
|
};
|