fixes
This commit is contained in:
parent
2630513c83
commit
1beaac8e2d
|
@ -17,7 +17,7 @@ import { PushNotificationService } from '@/core/PushNotificationService.js';
|
||||||
import { NotificationEntityService } from '@/core/entities/NotificationEntityService.js';
|
import { NotificationEntityService } from '@/core/entities/NotificationEntityService.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
import { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NotificationService implements OnApplicationShutdown {
|
export class NotificationService implements OnApplicationShutdown {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import { UploadPartCommand, CompleteMultipartUploadCommand, CreateMultipartUploa
|
||||||
import { mockClient } from 'aws-sdk-client-mock';
|
import { mockClient } from 'aws-sdk-client-mock';
|
||||||
import { GlobalModule } from '@/GlobalModule.js';
|
import { GlobalModule } from '@/GlobalModule.js';
|
||||||
import { CoreModule } from '@/core/CoreModule.js';
|
import { CoreModule } from '@/core/CoreModule.js';
|
||||||
import { S3Service } from '@/core/S3Service';
|
import { S3Service } from '@/core/S3Service.js';
|
||||||
import { Meta } from '@/models';
|
import { MiMeta } from '@/models/index.js';
|
||||||
import type { TestingModule } from '@nestjs/testing';
|
import type { TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
describe('S3Service', () => {
|
describe('S3Service', () => {
|
||||||
|
@ -40,7 +40,7 @@ describe('S3Service', () => {
|
||||||
test('upload a file', async () => {
|
test('upload a file', async () => {
|
||||||
s3Mock.on(PutObjectCommand).resolves({});
|
s3Mock.on(PutObjectCommand).resolves({});
|
||||||
|
|
||||||
await s3Service.upload({ objectStorageRegion: 'us-east-1' } as Meta, {
|
await s3Service.upload({ objectStorageRegion: 'us-east-1' } as MiMeta, {
|
||||||
Bucket: 'fake',
|
Bucket: 'fake',
|
||||||
Key: 'fake',
|
Key: 'fake',
|
||||||
Body: 'x',
|
Body: 'x',
|
||||||
|
@ -52,7 +52,7 @@ describe('S3Service', () => {
|
||||||
s3Mock.on(UploadPartCommand).resolves({ ETag: '1' });
|
s3Mock.on(UploadPartCommand).resolves({ ETag: '1' });
|
||||||
s3Mock.on(CompleteMultipartUploadCommand).resolves({ Bucket: 'fake', Key: 'fake' });
|
s3Mock.on(CompleteMultipartUploadCommand).resolves({ Bucket: 'fake', Key: 'fake' });
|
||||||
|
|
||||||
await s3Service.upload({} as Meta, {
|
await s3Service.upload({} as MiMeta, {
|
||||||
Bucket: 'fake',
|
Bucket: 'fake',
|
||||||
Key: 'fake',
|
Key: 'fake',
|
||||||
Body: 'x'.repeat(8 * 1024 * 1024 + 1), // デフォルトpartSizeにしている 8 * 1024 * 1024 を越えるサイズ
|
Body: 'x'.repeat(8 * 1024 * 1024 + 1), // デフォルトpartSizeにしている 8 * 1024 * 1024 を越えるサイズ
|
||||||
|
@ -62,7 +62,7 @@ describe('S3Service', () => {
|
||||||
test('upload a file error', async () => {
|
test('upload a file error', async () => {
|
||||||
s3Mock.on(PutObjectCommand).rejects({ name: 'Fake Error' });
|
s3Mock.on(PutObjectCommand).rejects({ name: 'Fake Error' });
|
||||||
|
|
||||||
await expect(s3Service.upload({ objectStorageRegion: 'us-east-1' } as Meta, {
|
await expect(s3Service.upload({ objectStorageRegion: 'us-east-1' } as MiMeta, {
|
||||||
Bucket: 'fake',
|
Bucket: 'fake',
|
||||||
Key: 'fake',
|
Key: 'fake',
|
||||||
Body: 'x',
|
Body: 'x',
|
||||||
|
@ -72,7 +72,7 @@ describe('S3Service', () => {
|
||||||
test('upload a large file error', async () => {
|
test('upload a large file error', async () => {
|
||||||
s3Mock.on(UploadPartCommand).rejects();
|
s3Mock.on(UploadPartCommand).rejects();
|
||||||
|
|
||||||
await expect(s3Service.upload({} as Meta, {
|
await expect(s3Service.upload({} as MiMeta, {
|
||||||
Bucket: 'fake',
|
Bucket: 'fake',
|
||||||
Key: 'fake',
|
Key: 'fake',
|
||||||
Body: 'x'.repeat(8 * 1024 * 1024 + 1), // デフォルトpartSizeにしている 8 * 1024 * 1024 を越えるサイズ
|
Body: 'x'.repeat(8 * 1024 * 1024 + 1), // デフォルトpartSizeにしている 8 * 1024 * 1024 を越えるサイズ
|
||||||
|
|
|
@ -18,11 +18,11 @@ import { CoreModule } from '@/core/CoreModule.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { IActor, IApDocument, ICollection, IPost } from '@/core/activitypub/type.js';
|
import type { IActor, IApDocument, ICollection, IPost } from '@/core/activitypub/type.js';
|
||||||
import { Meta, Note } from '@/models/index.js';
|
import { MiMeta, MiNote } from '@/models/index.js';
|
||||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { DownloadService } from '@/core/DownloadService.js';
|
import { DownloadService } from '@/core/DownloadService.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import type { RemoteUser } from '@/models/entities/User.js';
|
import type { MiRemoteUser } from '@/models/entities/User.js';
|
||||||
import { MockResolver } from '../misc/mock-resolver.js';
|
import { MockResolver } from '../misc/mock-resolver.js';
|
||||||
|
|
||||||
const host = 'https://host1.test';
|
const host = 'https://host1.test';
|
||||||
|
@ -75,7 +75,7 @@ function createRandomFeaturedCollection(actor: NonTransientIActor, length: numbe
|
||||||
async function createRandomRemoteUser(
|
async function createRandomRemoteUser(
|
||||||
resolver: MockResolver,
|
resolver: MockResolver,
|
||||||
personService: ApPersonService,
|
personService: ApPersonService,
|
||||||
): Promise<RemoteUser> {
|
): Promise<MiRemoteUser> {
|
||||||
const actor = createRandomActor();
|
const actor = createRandomActor();
|
||||||
resolver.register(actor.id, actor);
|
resolver.register(actor.id, actor);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ describe('ActivityPub', () => {
|
||||||
cacheRemoteSensitiveFiles: true,
|
cacheRemoteSensitiveFiles: true,
|
||||||
blockedHosts: [] as string[],
|
blockedHosts: [] as string[],
|
||||||
sensitiveWords: [] as string[],
|
sensitiveWords: [] as string[],
|
||||||
} as Meta;
|
} as MiMeta;
|
||||||
let meta = metaInitial;
|
let meta = metaInitial;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -109,7 +109,7 @@ describe('ActivityPub', () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.overrideProvider(MetaService).useValue({
|
.overrideProvider(MetaService).useValue({
|
||||||
async fetch(): Promise<Meta> {
|
async fetch(): Promise<MiMeta> {
|
||||||
return meta;
|
return meta;
|
||||||
},
|
},
|
||||||
}).compile();
|
}).compile();
|
||||||
|
@ -199,7 +199,7 @@ describe('ActivityPub', () => {
|
||||||
rendererService.renderAnnounce(null, {
|
rendererService.renderAnnounce(null, {
|
||||||
createdAt: new Date(0),
|
createdAt: new Date(0),
|
||||||
visibility: 'followers',
|
visibility: 'followers',
|
||||||
} as Note);
|
} as MiNote);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { entity as TestGroupedChartEntity } from '@/core/chart/charts/entities/t
|
||||||
import { entity as TestUniqueChartEntity } from '@/core/chart/charts/entities/test-unique.js';
|
import { entity as TestUniqueChartEntity } from '@/core/chart/charts/entities/test-unique.js';
|
||||||
import { entity as TestIntersectionChartEntity } from '@/core/chart/charts/entities/test-intersection.js';
|
import { entity as TestIntersectionChartEntity } from '@/core/chart/charts/entities/test-intersection.js';
|
||||||
import { loadConfig } from '@/config.js';
|
import { loadConfig } from '@/config.js';
|
||||||
import type { AppLockService } from '@/core/AppLockService';
|
import type { AppLockService } from '@/core/AppLockService.js';
|
||||||
import Logger from '@/logger.js';
|
import Logger from '@/logger.js';
|
||||||
|
|
||||||
describe('Chart', () => {
|
describe('Chart', () => {
|
||||||
|
|
|
@ -6,42 +6,42 @@
|
||||||
import { correctFilename } from '@/misc/correct-filename.js';
|
import { correctFilename } from '@/misc/correct-filename.js';
|
||||||
|
|
||||||
describe(correctFilename, () => {
|
describe(correctFilename, () => {
|
||||||
it('no ext to null', () => {
|
it('no ext to null', () => {
|
||||||
expect(correctFilename('test', null)).toBe('test.unknown');
|
expect(correctFilename('test', null)).toBe('test.unknown');
|
||||||
});
|
});
|
||||||
it('no ext to jpg', () => {
|
it('no ext to jpg', () => {
|
||||||
expect(correctFilename('test', 'jpg')).toBe('test.jpg');
|
expect(correctFilename('test', 'jpg')).toBe('test.jpg');
|
||||||
});
|
});
|
||||||
it('jpg to webp', () => {
|
it('jpg to webp', () => {
|
||||||
expect(correctFilename('test.jpg', 'webp')).toBe('test.jpg.webp');
|
expect(correctFilename('test.jpg', 'webp')).toBe('test.jpg.webp');
|
||||||
});
|
});
|
||||||
it('jpg to .webp', () => {
|
it('jpg to .webp', () => {
|
||||||
expect(correctFilename('test.jpg', '.webp')).toBe('test.jpg.webp');
|
expect(correctFilename('test.jpg', '.webp')).toBe('test.jpg.webp');
|
||||||
});
|
});
|
||||||
it('jpeg to jpg', () => {
|
it('jpeg to jpg', () => {
|
||||||
expect(correctFilename('test.jpeg', 'jpg')).toBe('test.jpeg');
|
expect(correctFilename('test.jpeg', 'jpg')).toBe('test.jpeg');
|
||||||
});
|
});
|
||||||
it('JPEG to jpg', () => {
|
it('JPEG to jpg', () => {
|
||||||
expect(correctFilename('test.JPEG', 'jpg')).toBe('test.JPEG');
|
expect(correctFilename('test.JPEG', 'jpg')).toBe('test.JPEG');
|
||||||
});
|
});
|
||||||
it('jpg to jpg', () => {
|
it('jpg to jpg', () => {
|
||||||
expect(correctFilename('test.jpg', 'jpg')).toBe('test.jpg');
|
expect(correctFilename('test.jpg', 'jpg')).toBe('test.jpg');
|
||||||
});
|
});
|
||||||
it('JPG to jpg', () => {
|
it('JPG to jpg', () => {
|
||||||
expect(correctFilename('test.JPG', 'jpg')).toBe('test.JPG');
|
expect(correctFilename('test.JPG', 'jpg')).toBe('test.JPG');
|
||||||
});
|
});
|
||||||
it('tiff to tif', () => {
|
it('tiff to tif', () => {
|
||||||
expect(correctFilename('test.tiff', 'tif')).toBe('test.tiff');
|
expect(correctFilename('test.tiff', 'tif')).toBe('test.tiff');
|
||||||
});
|
});
|
||||||
it('skip gz', () => {
|
it('skip gz', () => {
|
||||||
expect(correctFilename('test.unitypackage', 'gz')).toBe('test.unitypackage');
|
expect(correctFilename('test.unitypackage', 'gz')).toBe('test.unitypackage');
|
||||||
});
|
});
|
||||||
it('skip text file', () => {
|
it('skip text file', () => {
|
||||||
expect(correctFilename('test.txt', null)).toBe('test.txt');
|
expect(correctFilename('test.txt', null)).toBe('test.txt');
|
||||||
});
|
});
|
||||||
it('unknown', () => {
|
it('unknown', () => {
|
||||||
expect(correctFilename('test.hoge', null)).toBe('test.hoge');
|
expect(correctFilename('test.hoge', null)).toBe('test.hoge');
|
||||||
});
|
});
|
||||||
test('non ascii with space', () => {
|
test('non ascii with space', () => {
|
||||||
expect(correctFilename('ファイル 名前', 'jpg')).toBe('ファイル 名前.jpg');
|
expect(correctFilename('ファイル 名前', 'jpg')).toBe('ファイル 名前.jpg');
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { readFile } from 'node:fs/promises';
|
||||||
import { isAbsolute, basename } from 'node:path';
|
import { isAbsolute, basename } from 'node:path';
|
||||||
import { inspect } from 'node:util';
|
import { inspect } from 'node:util';
|
||||||
import WebSocket, { ClientOptions } from 'ws';
|
import WebSocket, { ClientOptions } from 'ws';
|
||||||
import fetch, { Blob, File, RequestInit } from 'node-fetch';
|
import fetch, { File, RequestInit } from 'node-fetch';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom';
|
||||||
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
||||||
|
|
Loading…
Reference in New Issue