fix: various fixes to sentry-reported errors and more

This commit is contained in:
Hampus Kraft
2026-02-18 15:38:51 +00:00
parent 302c0d2a0c
commit 0517a966a3
357 changed files with 25420 additions and 16281 deletions

View File

@@ -44,6 +44,7 @@ import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidat
import {MaxFavoriteMemesError} from '@fluxer/errors/src/domains/core/MaxFavoriteMemesError';
import {MediaMetadataError} from '@fluxer/errors/src/domains/core/MediaMetadataError';
import {UnknownFavoriteMemeError} from '@fluxer/errors/src/domains/core/UnknownFavoriteMemeError';
import {normalizeFilename} from '@fluxer/schema/src/primitives/FileValidators';
import mime from 'mime';
export class FavoriteMemeService {
@@ -431,8 +432,10 @@ export class FavoriteMemeService {
const extension = mime.getExtension(contentType) || 'bin';
try {
const urlPath = new URL(url).pathname;
const urlFilename = urlPath.split('/').pop() || 'media';
return urlFilename.includes('.') ? urlFilename : `${urlFilename}.${extension}`;
const rawSegment = urlPath.split('/').pop() || 'media';
const decoded = decodeURIComponent(rawSegment);
const base = decoded.includes('.') ? decoded : `${decoded}.${extension}`;
return normalizeFilename(base) || `media.${extension}`;
} catch {
return `media.${extension}`;
}
@@ -675,8 +678,12 @@ export class FavoriteMemeService {
private extractFilenameFromUrl(url: string): string | null {
try {
const urlObj = new URL(url);
const parts = urlObj.pathname.split('/');
return parts[parts.length - 1] || null;
const rawSegment = urlObj.pathname.split('/').pop();
if (!rawSegment) {
return null;
}
const decoded = decodeURIComponent(rawSegment);
return normalizeFilename(decoded) || null;
} catch {
return null;
}

View File

@@ -183,8 +183,23 @@ describe('Favorite Meme Extended Tests', () => {
});
describe('Personal Notes (DM to self with meme)', () => {
test('should send favorite meme as attachment in personal notes', async () => {
async function createAccountWithPersonalNotes(harness: ApiTestHarness) {
const account = await createTestAccountForAttachmentTests(harness);
await createBuilderWithoutAuth(harness)
.post('/test/rpc-session-init')
.body({
type: 'session',
token: account.token,
version: 1,
ip: '127.0.0.1',
})
.expect(HTTP_STATUS.OK)
.execute();
return account;
}
test('should send favorite meme as attachment in personal notes', async () => {
const account = await createAccountWithPersonalNotes(harness);
const meme = await createFavoriteMemeFromUrl(harness, account.token, {
url: TEST_IMAGE_URL,
@@ -207,7 +222,7 @@ describe('Favorite Meme Extended Tests', () => {
});
test('should fetch personal note message with meme attachment', async () => {
const account = await createTestAccountForAttachmentTests(harness);
const account = await createAccountWithPersonalNotes(harness);
const meme = await createFavoriteMemeFromUrl(harness, account.token, {
url: TEST_IMAGE_URL,