Merge branch 'staging' into woo-yeah

This commit is contained in:
Cohee
2025-01-27 20:56:04 +02:00
22 changed files with 54 additions and 28 deletions

View File

@ -74,12 +74,18 @@ async function writeCharacterData(inputFile, data, outputFile, request, crop = u
* Read the image, resize, and save it as a PNG into the buffer.
* @returns {Promise<Buffer>} Image buffer
*/
function getInputImage() {
if (Buffer.isBuffer(inputFile)) {
return parseImageBuffer(inputFile, crop);
}
async function getInputImage() {
try {
if (Buffer.isBuffer(inputFile)) {
return await parseImageBuffer(inputFile, crop);
}
return tryReadImage(inputFile, crop);
return await tryReadImage(inputFile, crop);
} catch (error) {
const message = Buffer.isBuffer(inputFile) ? 'Failed to read image buffer.' : `Failed to read image: ${inputFile}.`;
console.warn(message, 'Using a fallback image.', error);
return await fs.promises.readFile(defaultAvatarPath);
}
}
const inputImage = await getInputImage();

View File

@ -458,7 +458,8 @@ export function getPasswordSalt() {
*/
export function getCookieSessionName() {
// Get server hostname and hash it to generate a session suffix
const suffix = crypto.createHash('sha256').update(os.hostname()).digest('hex').slice(0, 8);
const hostname = os.hostname() || 'localhost';
const suffix = crypto.createHash('sha256').update(hostname).digest('hex').slice(0, 8);
return `session-${suffix}`;
}