Skip to content

Commit

Permalink
Add logging of automatic tier assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lezek123 committed Dec 2, 2024
1 parent 8ac5cbe commit 23300c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/services/httpApi/controllers/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
VerifyChannelDto,
WhitelistChannelDto,
} from '../dtos'
import { Logger } from 'winston'

@Controller('channels')
@ApiTags('channels')
Expand All @@ -51,7 +52,8 @@ export class ChannelsController {
private qnApi: QueryNodeApi,
private dynamodbService: DynamodbService,
private youtubePollingService: YoutubePollingService,
private contentProcessingClient: ContentProcessingClient
private contentProcessingClient: ContentProcessingClient,
private logger: Logger
) {}

@Post()
Expand Down Expand Up @@ -132,6 +134,13 @@ export class ChannelsController {
joystreamChannelLanguageIso,
}

if (existingChannel && existingChannel.preOptOutStatus) {
this.logger.info(
`Automatically assigned previous ${existingChannel.preOptOutStatus} tier ` +
`to channel ${joystreamChannelId} (${existingChannel.id})`
)
}

// save user and channel
await this.saveUserAndChannel(updatedUser, updatedChannel)

Expand Down
7 changes: 6 additions & 1 deletion src/services/httpApi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from './controllers'
import { MembershipController } from './controllers/membership'
import { ReferrersController } from './controllers/referrers'
import { Logger } from 'winston'

class ApiModule {}

Expand Down Expand Up @@ -70,6 +71,7 @@ export async function bootstrapHttpApi(
await cryptoWaitReady()

const dynamodbService = new DynamodbService(config.aws, false)
const logger = logging.createLogger('HttpApi')

const objectAppModule: DynamicModule = {
module: ApiModule,
Expand Down Expand Up @@ -105,6 +107,10 @@ export async function bootstrapHttpApi(
provide: ContentProcessingClient,
useValue: contentProcessingClient,
},
{
provide: Logger,
useValue: logger,
},
{
provide: 'youtube',
useValue: youtubeApi,
Expand Down Expand Up @@ -146,7 +152,6 @@ export async function bootstrapHttpApi(
})

// API request/response logging
const logger = logging.createLogger('HttpApi')
app.use((request: express.Request, response: express.Response, next: express.NextFunction) => {
const { method, originalUrl } = request

Expand Down

0 comments on commit 23300c4

Please sign in to comment.