mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-22 17:43:09 +02:00
Compare commits
51 commits
455ca3494f
...
5ef39c8644
Author | SHA1 | Date | |
---|---|---|---|
|
5ef39c8644 | ||
|
e0afeff248 | ||
|
cfc8081cec | ||
|
011ccd3a9a | ||
|
28065fc1d1 | ||
|
960f4fcff7 | ||
|
92eec2178f | ||
|
56dca6dbf5 | ||
|
2a634e0309 | ||
|
e6970a0e7c | ||
|
571272a564 | ||
|
30bb0f60a2 | ||
|
328546c4cd | ||
|
4271402e0d | ||
|
0e8cdb30b7 | ||
|
435cab01c8 | ||
|
25e6409cc9 | ||
|
f4e89f2e6b | ||
|
2cad97c1ab | ||
|
6ecfe7c7c3 | ||
|
23f476dbf3 | ||
|
7a1251423f | ||
|
7f5492a395 | ||
|
11d9fd9199 | ||
|
6132bc3b3e | ||
|
fef7a7b99a | ||
|
1948ca9aa8 | ||
|
848e1f9a56 | ||
|
9c4353ee79 | ||
|
a6e257f502 | ||
|
310e1a1262 | ||
|
15f3c046d1 | ||
|
01d695428a | ||
|
acf3e3460f | ||
|
4c8116859c | ||
|
0e13397db7 | ||
|
ad8818508f | ||
|
d444ee662f | ||
|
4c354fff2d | ||
|
b81448edf6 | ||
|
134d2895f0 | ||
|
7ba8fde9b9 | ||
|
1022280465 | ||
|
021d3924e6 | ||
|
b6d50d781f | ||
|
1d411bb885 | ||
|
f7afd1ae4a | ||
|
1ef1f2a03c | ||
|
829ce4f86a | ||
|
6d5d863150 | ||
|
fc7d4bc420 |
8 changed files with 146 additions and 9 deletions
|
@ -55,6 +55,8 @@ getImageTag:
|
||||||
only:
|
only:
|
||||||
- stable
|
- stable
|
||||||
- develop
|
- develop
|
||||||
|
- tags
|
||||||
|
|
||||||
buildDocker:
|
buildDocker:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
needs:
|
needs:
|
||||||
|
@ -78,6 +80,8 @@ buildDocker:
|
||||||
only:
|
only:
|
||||||
- stable
|
- stable
|
||||||
- develop
|
- develop
|
||||||
|
- tags
|
||||||
|
|
||||||
mergeManifests:
|
mergeManifests:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
needs:
|
needs:
|
||||||
|
@ -103,3 +107,4 @@ mergeManifests:
|
||||||
only:
|
only:
|
||||||
- stable
|
- stable
|
||||||
- develop
|
- develop
|
||||||
|
- tags
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sharkey",
|
"name": "sharkey",
|
||||||
"version": "2024.3.1",
|
"version": "2024.3.2-devel",
|
||||||
"codename": "shonk",
|
"codename": "shonk",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
"stringz": "2.1.0",
|
"stringz": "2.1.0",
|
||||||
"systeminformation": "5.22.0",
|
"systeminformation": "5.22.0",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
"tmp": "0.2.2",
|
"tmp": "0.2.3",
|
||||||
"tsc-alias": "1.8.8",
|
"tsc-alias": "1.8.8",
|
||||||
"tsconfig-paths": "4.2.0",
|
"tsconfig-paths": "4.2.0",
|
||||||
"typeorm": "0.3.20",
|
"typeorm": "0.3.20",
|
||||||
|
|
|
@ -212,6 +212,8 @@ export function loadConfig(): Config {
|
||||||
{} as Source,
|
{} as Source,
|
||||||
) as Source;
|
) as Source;
|
||||||
|
|
||||||
|
applyEnvOverrides(config);
|
||||||
|
|
||||||
const url = tryCreateUrl(config.url);
|
const url = tryCreateUrl(config.url);
|
||||||
const version = meta.version;
|
const version = meta.version;
|
||||||
const host = url.host;
|
const host = url.host;
|
||||||
|
@ -304,3 +306,123 @@ function convertRedisOptions(options: RedisOptionsSource, host: string): RedisOp
|
||||||
db: options.db ?? 0,
|
db: options.db ?? 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
this function allows overriding any string-valued config option with
|
||||||
|
a sensible-named environment variable
|
||||||
|
|
||||||
|
e.g. `MK_CONFIG_MEILISEARCH_APIKEY` sets `config.meilisearch.apikey`
|
||||||
|
|
||||||
|
you can also override a single `dbSlave` value,
|
||||||
|
e.g. `MK_CONFIG_DBSLAVES_1_PASS` sets the password for the 2nd
|
||||||
|
database replica (the first one would be
|
||||||
|
`MK_CONFIG_DBSLAVES_0_PASS`); in this case, `config.dbSlaves` must
|
||||||
|
be set to an array of the right size already in the file
|
||||||
|
|
||||||
|
values can be read from files, too: setting `MK_DB_PASS_FILE` to
|
||||||
|
`/some/file` would set the main database password to the contents of
|
||||||
|
`/some/file` (trimmed of whitespaces)
|
||||||
|
*/
|
||||||
|
function applyEnvOverrides(config: Source) {
|
||||||
|
// these inner functions recurse through the config structure, using
|
||||||
|
// the given steps, building the env variable name
|
||||||
|
|
||||||
|
function _apply_top(steps: (string | number)[]) {
|
||||||
|
_walk('', [], steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _walk(name: string, path: (string | number)[], steps: (string | number)[]) {
|
||||||
|
// are there more steps after this one? recurse
|
||||||
|
if (steps.length > 1) {
|
||||||
|
const thisStep = steps.shift();
|
||||||
|
if (thisStep === null || thisStep === undefined) return;
|
||||||
|
|
||||||
|
// if a step is not a simple value, iterate through it
|
||||||
|
if (typeof thisStep === 'object') {
|
||||||
|
for (const thisOneStep of thisStep) {
|
||||||
|
_descend(name, path, thisOneStep, steps);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_descend(name, path, thisStep, steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
// the actual override has happened at the bottom of the
|
||||||
|
// recursion, we're done
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the last step, same thing as above
|
||||||
|
const lastStep = steps[0];
|
||||||
|
|
||||||
|
if (typeof lastStep === 'object') {
|
||||||
|
for (const lastOneStep of lastStep) {
|
||||||
|
_lastBit(name, path, lastOneStep);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_lastBit(name, path, lastStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _step2name(step: string|number): string {
|
||||||
|
return step.toString().replaceAll(/[^a-z0-9]+/gi,'').toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// this recurses down, bailing out if there's no config to override
|
||||||
|
function _descend(name: string, path: (string | number)[], thisStep: string | number, steps: (string | number)[]) {
|
||||||
|
name = `${name}${_step2name(thisStep)}_`;
|
||||||
|
path = [ ...path, thisStep ];
|
||||||
|
_walk(name, path, steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the bottom of the recursion: look at the environment and
|
||||||
|
// set the value
|
||||||
|
function _lastBit(name: string, path: (string | number)[], lastStep: string | number) {
|
||||||
|
name = `MK_CONFIG_${name}${_step2name(lastStep)}`;
|
||||||
|
|
||||||
|
const val = process.env[name];
|
||||||
|
if (val != null && val != undefined) {
|
||||||
|
_assign(path, lastStep, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
const file = process.env[`${name}_FILE`];
|
||||||
|
if (file) {
|
||||||
|
_assign(path, lastStep, fs.readFileSync(file, 'utf-8').trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const alwaysStrings = { 'chmodSocket': 1 };
|
||||||
|
|
||||||
|
function _assign(path: (string | number)[], lastStep: string | number, value: string) {
|
||||||
|
let thisConfig = config;
|
||||||
|
for (const step of path) {
|
||||||
|
if (!thisConfig[step]) {
|
||||||
|
thisConfig[step] = {};
|
||||||
|
}
|
||||||
|
thisConfig = thisConfig[step];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!alwaysStrings[lastStep]) {
|
||||||
|
if (value.match(/^[0-9]+$/)) {
|
||||||
|
value = parseInt(value);
|
||||||
|
} else if (value.match(/^(true|false)$/i)) {
|
||||||
|
value = !!value.match(/^true$/i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
thisConfig[lastStep] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// these are all the settings that can be overridden
|
||||||
|
|
||||||
|
_apply_top([['url', 'port', 'socket', 'chmodSocket', 'disableHsts']]);
|
||||||
|
_apply_top(['db', ['host', 'port', 'db', 'user', 'pass']]);
|
||||||
|
_apply_top(['dbSlaves', config.dbSlaves?.keys(), ['host', 'port', 'db', 'user', 'pass']]);
|
||||||
|
_apply_top([
|
||||||
|
['redis', 'redisForPubsub', 'redisForJobQueue', 'redisForTimelines'],
|
||||||
|
['host','port','username','pass','db','prefix'],
|
||||||
|
]);
|
||||||
|
_apply_top(['meilisearch', ['host', 'port', 'apikey', 'ssl', 'index', 'scope']]);
|
||||||
|
_apply_top([['clusterLimit', 'deliverJobConcurrency', 'inboxJobConcurrency', 'relashionshipJobConcurrency', 'deliverJobPerSec', 'inboxJobPerSec', 'relashionshipJobPerSec', 'deliverJobMaxAttempts', 'inboxJobMaxAttempts']]);
|
||||||
|
_apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaProxy', 'videoThumbnailGenerator']]);
|
||||||
|
_apply_top([['maxFileSize', 'maxNoteLength', 'pidFile']]);
|
||||||
|
}
|
||||||
|
|
|
@ -192,6 +192,7 @@ export class FileServerService {
|
||||||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
reply.header('Accept-Ranges', 'bytes');
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
|
reply.code(206);
|
||||||
} else {
|
} else {
|
||||||
image = {
|
image = {
|
||||||
data: fs.createReadStream(file.path),
|
data: fs.createReadStream(file.path),
|
||||||
|
@ -261,7 +262,6 @@ export class FileServerService {
|
||||||
const parts = range.replace(/bytes=/, '').split('-');
|
const parts = range.replace(/bytes=/, '').split('-');
|
||||||
const start = parseInt(parts[0], 10);
|
const start = parseInt(parts[0], 10);
|
||||||
let end = parts[1] ? parseInt(parts[1], 10) : file.file.size - 1;
|
let end = parts[1] ? parseInt(parts[1], 10) : file.file.size - 1;
|
||||||
console.log(end);
|
|
||||||
if (end > file.file.size) {
|
if (end > file.file.size) {
|
||||||
end = file.file.size - 1;
|
end = file.file.size - 1;
|
||||||
}
|
}
|
||||||
|
@ -431,6 +431,7 @@ export class FileServerService {
|
||||||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
reply.header('Accept-Ranges', 'bytes');
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
|
reply.code(206);
|
||||||
} else {
|
} else {
|
||||||
image = {
|
image = {
|
||||||
data: fs.createReadStream(file.path),
|
data: fs.createReadStream(file.path),
|
||||||
|
@ -527,6 +528,9 @@ export class FileServerService {
|
||||||
if (!file.storedInternal) {
|
if (!file.storedInternal) {
|
||||||
if (!(file.isLink && file.uri)) return '204';
|
if (!(file.isLink && file.uri)) return '204';
|
||||||
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
|
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
|
||||||
|
if (!file.size) {
|
||||||
|
file.size = (await fs.promises.stat(result.path)).size;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
url: file.uri,
|
url: file.uri,
|
||||||
|
|
|
@ -5,8 +5,8 @@ block vars
|
||||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
||||||
- const url = `${config.url}/notes/${note.id}`;
|
- const url = `${config.url}/notes/${note.id}`;
|
||||||
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
||||||
- const images = (note.files || []).filter(file => file.type.startsWith('image/') && !file.isSensitive)
|
- const images = note.cw ? [] : (note.files || []).filter(file => file.type.startsWith('image/') && !file.isSensitive)
|
||||||
- const videos = (note.files || []).filter(file => file.type.startsWith('video/') && !file.isSensitive)
|
- const videos = note.cw ? [] : (note.files || []).filter(file => file.type.startsWith('video/') && !file.isSensitive)
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
|
@ -392,8 +392,8 @@ importers:
|
||||||
specifier: 1.6.0
|
specifier: 1.6.0
|
||||||
version: 1.6.0
|
version: 1.6.0
|
||||||
tmp:
|
tmp:
|
||||||
specifier: 0.2.2
|
specifier: 0.2.3
|
||||||
version: 0.2.2
|
version: 0.2.3
|
||||||
tsc-alias:
|
tsc-alias:
|
||||||
specifier: 1.8.8
|
specifier: 1.8.8
|
||||||
version: 1.8.8
|
version: 1.8.8
|
||||||
|
@ -18813,6 +18813,12 @@ packages:
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
rimraf: 5.0.5
|
rimraf: 5.0.5
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/tmp@0.2.3:
|
||||||
|
resolution: {integrity: sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==}
|
||||||
|
engines: {node: '>=14.14'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/tmpl@1.0.5:
|
/tmpl@1.0.5:
|
||||||
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
|
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
|
||||||
|
|
Loading…
Reference in a new issue