refactor/perf(backend): provide metadata statically (#14601)
* wip * Update ReactionService.ts * Update ApiCallService.ts * Update timeline.ts * Update GlobalModule.ts * Update GlobalModule.ts * Update NoteEntityService.ts * wip * wip * wip * Update ApPersonService.ts * wip * Update GlobalModule.ts * Update mock-resolver.ts * Update RoleService.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * clean up * Update utils.ts * Update UtilityService.ts * Revert "Update utils.ts" This reverts commita27d4be764
. * Revert "Update UtilityService.ts" This reverts commite5fd9e004c
. * vuwa- * Revert "vuwa-" This reverts commit0c3bd12472
. * Update entry.ts * Update entry.ts * Update entry.ts * Update entry.ts * Update jest.setup.ts
This commit is contained in:
@@ -24,7 +24,6 @@ import { MiMeta, MiNote, UserProfilesRepository } from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { DownloadService } from '@/core/DownloadService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import type { MiRemoteUser } from '@/models/User.js';
|
||||
import { genAidx } from '@/misc/id/aidx.js';
|
||||
import { MockResolver } from '../misc/mock-resolver.js';
|
||||
@@ -107,7 +106,14 @@ describe('ActivityPub', () => {
|
||||
sensitiveWords: [] as string[],
|
||||
prohibitedWords: [] as string[],
|
||||
} as MiMeta;
|
||||
let meta = metaInitial;
|
||||
const meta = { ...metaInitial };
|
||||
|
||||
function updateMeta(newMeta: Partial<MiMeta>): void {
|
||||
for (const key in meta) {
|
||||
delete (meta as any)[key];
|
||||
}
|
||||
Object.assign(meta, newMeta);
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
const app = await Test.createTestingModule({
|
||||
@@ -120,11 +126,8 @@ describe('ActivityPub', () => {
|
||||
};
|
||||
},
|
||||
})
|
||||
.overrideProvider(MetaService).useValue({
|
||||
async fetch(): Promise<MiMeta> {
|
||||
return meta;
|
||||
},
|
||||
}).compile();
|
||||
.overrideProvider(DI.meta).useFactory({ factory: () => meta })
|
||||
.compile();
|
||||
|
||||
await app.init();
|
||||
app.enableShutdownHooks();
|
||||
@@ -367,7 +370,7 @@ describe('ActivityPub', () => {
|
||||
});
|
||||
|
||||
test('cacheRemoteFiles=false disables caching', async () => {
|
||||
meta = { ...metaInitial, cacheRemoteFiles: false };
|
||||
updateMeta({ ...metaInitial, cacheRemoteFiles: false });
|
||||
|
||||
const imageObject: IApDocument = {
|
||||
type: 'Document',
|
||||
@@ -396,7 +399,7 @@ describe('ActivityPub', () => {
|
||||
});
|
||||
|
||||
test('cacheRemoteSensitiveFiles=false only affects sensitive files', async () => {
|
||||
meta = { ...metaInitial, cacheRemoteSensitiveFiles: false };
|
||||
updateMeta({ ...metaInitial, cacheRemoteSensitiveFiles: false });
|
||||
|
||||
const imageObject: IApDocument = {
|
||||
type: 'Document',
|
||||
|
Reference in New Issue
Block a user