@@ -12,6 +12,7 @@ import {
1212 Post ,
1313 Put ,
1414 UnauthorizedException ,
15+ UseGuards ,
1516} from '@nestjs/common'
1617import { ApiBody , ApiOperation , ApiResponse , ApiTags } from '@nestjs/swagger'
1718import { 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