feat(server): clean populated channels

This commit is contained in:
Marc 2020-09-21 17:49:50 +02:00
parent f0b86e7bd8
commit d0e458bd3a
3 changed files with 16 additions and 2 deletions

View file

@ -18,6 +18,7 @@
"ijmap",
"nestjs",
"tsviewer",
"uglifycss"
"uglifycss",
"cspacer0"
],
}

View file

@ -8,7 +8,7 @@ export class AppController {
@Get()
@Render('index.hbs')
async getIndex(): Promise<Record<string, unknown>> {
const channels = await this.teamspeakService.getPopulatedChannelList();
const channels = await this.teamspeakService.getCleanedPopulatedChannelList();
return { title: 'Cliffbreak.de TS-Viewer', channels };
}
}

View file

@ -78,4 +78,17 @@ export class TeamspeakService {
return channelList;
}
async getCleanedPopulatedChannelList(): Promise<IPopulatedChannel[]> {
const populatedChannels = await this.getPopulatedChannelList();
const channelList: IPopulatedChannel[] = [];
for(const channel of populatedChannels) {
if(channel.name.includes('[*spacer')) {
continue;
} else if(channel.name.includes('[cspacer0]')) {
channel.name = channel.name.replace('[cspacer0]', '');
}
channelList.push(channel);
}
return channelList;
}
}