Compare commits

...

2 Commits

Author SHA1 Message Date
imeepos 8eeedb444f fix: 修复DouyinAuthClient方法签名和添加详细调试信息
- 将getAccessToken方法改为async异步方法
- 在构造函数中添加配置和Client创建的调试信息
- 在getAccessToken方法中添加完整的调用流程调试
- 添加try-catch错误处理和详细的错误日志
- 隐藏敏感的clientSecret信息在日志中
2025-09-08 14:19:49 +08:00
imeepos d3562b4d36 debug: 添加DouyinAuthClient依赖注入调试信息和错误处理
- 在DouyinContentAdapter构造函数中添加调试日志
- 在getAccessToken方法中添加详细的错误检查和处理
- 将DouyinAuthClient添加到module的exports中
- 提供更详细的错误信息帮助诊断注入问题
2025-09-08 14:14:44 +08:00
3 changed files with 38 additions and 4 deletions

View File

@ -18,13 +18,29 @@ body:
export class DouyinAuthClient {
private readonly client: Client;
constructor(private config: ConfigService) {
console.log('DouyinAuthClient constructor - creating client with:', {
clientKey: this.config.get('BYTEDANCE_APP_ID') || '',
clientSecret: this.config.get('BYTEDANCE_APP_SECRET') ? '***' : 'empty'
});
this.client = new Client({
clientKey: this.config.get('BYTEDANCE_APP_ID') || '',
clientSecret: this.config.get('BYTEDANCE_APP_SECRET') || '',
})
});
console.log('DouyinAuthClient constructor - client created:', !!this.client);
console.log('DouyinAuthClient constructor - client.getAccessToken type:', typeof this.client.getAccessToken);
}
getAccessToken() {
return this.client.getAccessToken()
async getAccessToken() {
console.log('DouyinAuthClient.getAccessToken called');
console.log('client:', !!this.client);
console.log('client.getAccessToken type:', typeof this.client.getAccessToken);
try {
const result = await this.client.getAccessToken();
console.log('getAccessToken result:', result);
return result;
} catch (error) {
console.error('getAccessToken error:', error);
throw error;
}
}
}

View File

@ -36,6 +36,13 @@ export class DouyinContentAdapter extends BaseContentAdapter {
) {
super(httpService, configService, auditLogRepository);
// 调试:检查 douyinAuthClient 是否正确注入
console.log('DouyinContentAdapter constructor - douyinAuthClient:', this.douyinAuthClient);
console.log('douyinAuthClient type:', typeof this.douyinAuthClient);
if (this.douyinAuthClient) {
console.log('douyinAuthClient.getAccessToken type:', typeof this.douyinAuthClient.getAccessToken);
}
// 抖音开放平台配置clientKey/clientSecret 实际使用的是 APP_ID/APP_SECRET
this.douyinConfig = {
clientKey: this.configService.get('BYTEDANCE_APP_ID') || '',
@ -157,6 +164,17 @@ export class DouyinContentAdapter extends BaseContentAdapter {
* 访
*/
private async getAccessToken(): Promise<string> {
console.log('getAccessToken called - douyinAuthClient:', this.douyinAuthClient);
console.log('douyinAuthClient type:', typeof this.douyinAuthClient);
if (!this.douyinAuthClient) {
throw new Error('DouyinAuthClient 未正确注入');
}
if (typeof this.douyinAuthClient.getAccessToken !== 'function') {
throw new Error(`DouyinAuthClient.getAccessToken 不是函数,类型: ${typeof this.douyinAuthClient.getAccessToken}`);
}
return this.douyinAuthClient.getAccessToken().then(res => res.accessToken)
}

View File

@ -51,6 +51,6 @@ import { ContentAuditGuard } from './guards/content-audit.guard';
ContentAuditGuard,
],
controllers: [ContentModerationController],
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard],
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard, DouyinAuthClient],
})
export class ContentModerationModule {}