add option filePermissionBits to override permissions on locally-stored files

This is useful for custom deployments, such as using a reverse proxy to serve static files directly
This commit is contained in:
Hazelnoot 2024-11-28 19:56:26 -05:00
parent 0efd5eff2b
commit 3d3cf5bd7a
6 changed files with 38 additions and 4 deletions

View file

@ -115,6 +115,7 @@ type Source = {
};
pidFile: string;
filePermissionBits?: string;
};
export type Config = {
@ -212,6 +213,7 @@ export type Config = {
} | undefined;
pidFile: string;
filePermissionBits?: string;
};
const _filename = fileURLToPath(import.meta.url);
@ -347,6 +349,7 @@ export function loadConfig(): Config {
deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7),
import: config.import,
pidFile: config.pidFile,
filePermissionBits: config.filePermissionBits,
};
}
@ -452,7 +455,10 @@ function applyEnvOverrides(config: Source) {
}
}
const alwaysStrings = { 'chmodSocket': true } as { [key: string]: boolean };
const alwaysStrings: { [key in string]?: boolean } = {
'chmodSocket': true,
'filePermissionBits': true,
};
function _assign(path: (string | number)[], lastStep: string | number, value: string) {
let thisConfig = config as any;
@ -490,7 +496,7 @@ function applyEnvOverrides(config: Source) {
_apply_top(['sentryForBackend', 'enableNodeProfiling']);
_apply_top([['clusterLimit', 'deliverJobConcurrency', 'inboxJobConcurrency', 'relashionshipJobConcurrency', 'deliverJobPerSec', 'inboxJobPerSec', 'relashionshipJobPerSec', 'deliverJobMaxAttempts', 'inboxJobMaxAttempts']]);
_apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaProxy', 'proxyRemoteFiles', 'videoThumbnailGenerator']]);
_apply_top([['maxFileSize', 'maxNoteLength', 'maxRemoteNoteLength', 'maxAltTextLength', 'maxRemoteAltTextLength', 'pidFile']]);
_apply_top([['maxFileSize', 'maxNoteLength', 'maxRemoteNoteLength', 'maxAltTextLength', 'maxRemoteAltTextLength', 'pidFile', 'filePermissionBits']]);
_apply_top(['import', ['downloadTimeout', 'maxFileSize']]);
_apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature']]);
}