Skip to content

Commit 2aad464

Browse files
committed
address review comments
1 parent a9ab209 commit 2aad464

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/api/api-spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
]
102102
}
103103
},
104-
"/channels/yt-syncing/{joystreamChannelId}": {
104+
"/channels/{joystreamChannelId}/ingest": {
105105
"put": {
106106
"operationId": "ChannelsController_updateChannel",
107107
"summary": "",
@@ -150,7 +150,7 @@
150150
"description": "Authenticated endpoint to suspend given channel/s from YPP program",
151151
"parameters": [
152152
{
153-
"name": "ypp_owner_key",
153+
"name": "authorization",
154154
"required": true,
155155
"in": "header",
156156
"schema": {

packages/api/src/channels/channels.controller.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
Post,
1313
Put,
1414
UnauthorizedException,
15+
UseGuards,
1516
} from '@nestjs/common'
1617
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
1718
import { Channel, User } from '@youtube-sync/domain'
@@ -86,7 +87,7 @@ export class ChannelsController {
8687
}
8788
}
8889

89-
@Put('/yt-syncing/:joystreamChannelId')
90+
@Put(':joystreamChannelId/ingest')
9091
@ApiBody({ type: UpdateChannelDto })
9192
@ApiResponse({ type: ChannelDto })
9293
@ApiOperation({
@@ -105,13 +106,15 @@ export class ChannelsController {
105106
@Put('/suspend')
106107
@ApiBody({ type: SuspendChannelDto, isArray: true })
107108
@ApiResponse({ type: ChannelDto, isArray: true })
109+
@UseGuards()
108110
@ApiOperation({
109111
description: `Authenticated endpoint to suspend given channel/s from YPP program`,
110112
})
111113
async suspendChannels(
112-
@Headers('ypp_owner_key') yppOwnerKey: string,
114+
@Headers('authorization') authorizationHeader: string,
113115
@Body(new ParseArrayPipe({ items: SuspendChannelDto, whitelist: true })) channels: SuspendChannelDto[]
114116
) {
117+
const yppOwnerKey = authorizationHeader.split(' ')[1]
115118
if (yppOwnerKey !== process.env.YPP_OWNER_KEY) {
116119
throw new UnauthorizedException('Invalid YPP owner key')
117120
}
@@ -124,8 +127,8 @@ export class ChannelsController {
124127
if (isSuspended) {
125128
this.channelsService.update({ ...channel, isSuspended, shouldBeIngested: false })
126129
} else {
127-
// if channel suspension is revoked then its YT ingestion/syncing should be resumed
128-
this.channelsService.update({ ...channel, isSuspended, shouldBeIngested: true })
130+
// if channel suspension is revoked then its YT ingestion/syncing should not be resumed
131+
this.channelsService.update({ ...channel, isSuspended })
129132
}
130133
}
131134
} catch (error) {

0 commit comments

Comments
 (0)