|
|
@@ -52,6 +52,17 @@ export class ChannelService {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ // Check for duplicate channelId
|
|
|
+ const existingChannelId = await this.mongoPrismaService.channel.findFirst({
|
|
|
+ where: { channelId: dto.channelId },
|
|
|
+ });
|
|
|
+
|
|
|
+ if (existingChannelId) {
|
|
|
+ throw new BadRequestException(
|
|
|
+ `Channel with channelId "${dto.channelId}" already exists`,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
const now = this.now();
|
|
|
|
|
|
const channel = await this.mongoPrismaService.channel.create({
|
|
|
@@ -96,12 +107,27 @@ export class ChannelService {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ // check for duplicate channelId (excluding current channel)
|
|
|
+ const duplicateChannelId = await this.mongoPrismaService.channel.findFirst({
|
|
|
+ where: {
|
|
|
+ channelId: dto.channelId,
|
|
|
+ id: { not: dto.id },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ if (duplicateChannelId) {
|
|
|
+ throw new BadRequestException(
|
|
|
+ `Channel with channelId "${dto.channelId}" already exists`,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
const now = this.now();
|
|
|
|
|
|
try {
|
|
|
const channel = await this.mongoPrismaService.channel.update({
|
|
|
where: { id: dto.id },
|
|
|
data: {
|
|
|
+ channelId: dto.channelId,
|
|
|
name: dto.name,
|
|
|
landingUrl: dto.landingUrl,
|
|
|
videoCdn: this.trimOptional(dto.videoCdn) ?? null,
|