Skip to content

Commit 7b379cf

Browse files
committed
Merge branch 'develop' into unit-testing
2 parents 7286ab0 + e67663a commit 7b379cf

File tree

27 files changed

+654
-522
lines changed

27 files changed

+654
-522
lines changed

build.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs';
22
import { resolve } from 'path';
33

44
import { getLatestVersionSoundList } from './shared/features/sounds';
5-
import { SEARCH_INCLUDE_PATTERNS } from './shared/features/sounds/filterIncludePatterns';
65

76
function writeJSONFile(
87
dir: string,
@@ -17,7 +16,6 @@ function writeJSONFile(
1716
const dataDir = resolve(__dirname, 'server', 'public', 'data');
1817

1918
const soundListPath = 'soundList.json';
20-
const filteredSoundListPath = 'filteredSoundList.json';
2119

2220
// Try to create the output directory if it doesn't exist
2321
try {
@@ -29,9 +27,7 @@ try {
2927
}
3028

3129
// If the files already exist, exit early
32-
const files = [soundListPath, filteredSoundListPath].map((fileName) =>
33-
resolve(dataDir, fileName),
34-
);
30+
const files = [soundListPath].map((fileName) => resolve(dataDir, fileName));
3531

3632
if (files.every((file) => existsSync(file))) {
3733
console.log('Sound data files already exist; skipping generation.');
@@ -44,16 +40,5 @@ console.log('Generating sound data files...');
4440
// Filter the list to only include sounds that match the chosen patterns
4541
// (defined in the shared/ module)
4642
getLatestVersionSoundList().then((soundList) => {
47-
const filteredSoundList: string[] = Object.keys(soundList)
48-
.filter((sound) =>
49-
SEARCH_INCLUDE_PATTERNS.some((pattern) =>
50-
new RegExp(pattern).test(sound),
51-
),
52-
)
53-
.sort((a, b) =>
54-
a.localeCompare(b, undefined, { sensitivity: 'base', numeric: true }),
55-
);
56-
5743
writeJSONFile(dataDir, soundListPath, soundList);
58-
writeJSONFile(dataDir, filteredSoundListPath, filteredSoundList);
5944
});

pnpm-lock.yaml

Lines changed: 9 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.env.development.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ S3_SECRET=
3131
S3_REGION=
3232

3333
WHITELISTED_USERS=
34+
35+
DISCORD_WEBHOOK_URL=

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"@aws-sdk/client-s3": "^3.525.0",
2424
"@aws-sdk/s3-request-presigner": "^3.525.0",
25-
"@encode42/nbs.js": "^5.0.0",
25+
"@encode42/nbs.js": "^5.0.2",
2626
"@nestjs/common": "^10.0.0",
2727
"@nestjs/config": "^3.0.0",
2828
"@nestjs/core": "^10.0.0",

server/src/file/file.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ export class FileService {
111111
const command = new GetObjectCommand({
112112
Bucket: bucket,
113113
Key: key,
114-
ResponseContentDisposition: `attachment; filename="${filename
115-
.split('/')
116-
.pop()}"`,
114+
ResponseContentDisposition: `attachment; filename="${filename}"`,
117115
});
118116

119117
const signedUrl = await getSignedUrl(this.s3Client, command, {

server/src/song/entity/song.entity.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ export class Song {
8888

8989
@Prop({ type: SongStats, required: true })
9090
stats: SongStats;
91+
92+
// EXTERNAL ATTRIBUTES
93+
94+
@Prop({ type: String, required: false })
95+
webhookMessageId?: string | null;
9196
}
9297

9398
export const SongSchema = SchemaFactory.createForClass(Song);

server/src/song/song-upload/song-upload.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ export class SongUploadService {
5353
return this.soundsMapping;
5454
}
5555

56-
private async getValidSoundsSubset(): Promise<Set<string>> {
57-
// Creates a set of valid sound paths from filteredSoundList.json,
58-
// a manually-crafted subset of sounds from Minecraft
56+
private async getValidSoundsSubset() {
57+
// Creates a set of valid sound paths from the full list of sounds in Minecraft
5958

6059
if (!this.soundsSubset) {
6160
try {
6261
const response = await fetch(
63-
process.env.SERVER_URL + '/api/v1/data/filteredSoundList.json',
62+
process.env.SERVER_URL + '/api/v1/data/soundList.json',
6463
);
6564

66-
const soundList = (await response.json()) as string[];
65+
const soundMapping = (await response.json()) as Record<string, string>;
66+
const soundList = Object.keys(soundMapping);
6767
this.soundsSubset = new Set(soundList);
6868
} catch (e) {
6969
throw new HttpException(

0 commit comments

Comments
 (0)