Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/tasks/wizard-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export class WizardTaskService {
text: string,
repo?: Repository<Task>,
) {
// Check if auto-tag is enabled for this user
const isEnabled = await this.userService.isAutoTagEnabled(userId);
if (!isEnabled) {
return null;
}

const lang = await this.getUserLanguage(userId);
return this.create(
{
Expand All @@ -111,6 +117,14 @@ export class WizardTaskService {
parentTask: Task,
repo?: Repository<Task>,
) {
// Check if auto-tag is enabled for this user
const isEnabled = await this.userService.isAutoTagEnabled(
parentTask.userId,
);
if (!isEnabled) {
return null;
}

const lang = await this.getUserLanguage(parentTask.userId);
return this.create(
{
Expand Down
2 changes: 1 addition & 1 deletion src/user/dto/create-user-option.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IsString, MaxLength } from 'class-validator';

export class CreateUserOptionDto {
@IsString()
@MaxLength(20)
@MaxLength(64)
name: string;

@IsString()
Expand Down
2 changes: 1 addition & 1 deletion src/user/user.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ describe('UserController (e2e)', () => {
await client
.post('/api/v1/user/option')
.send({
name: 'a'.repeat(21), // Too long
name: 'a'.repeat(65), // Too long
value: 'test',
})
.expect(HttpStatus.BAD_REQUEST);
Expand Down
15 changes: 15 additions & 0 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,19 @@ export class UserService {
option.value = value;
return await this.userOptionRepository.save(option);
}

async isAutoTagEnabled(
userId: string,
entityManager?: EntityManager,
): Promise<boolean> {
const option = await this.getOption(
userId,
'enable_ai_tag_extraction',
entityManager,
);
if (!option) {
return true; // Default: enabled
}
return option.value === 'true';
}
}
8 changes: 5 additions & 3 deletions src/wizard/wizard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,11 @@ export class WizardService {
const extractTagsTask =
await this.wizardTaskService.createExtractTagsTaskFromTask(parentTask);

this.logger.debug(
`Triggered extract_tags task ${extractTagsTask.id} for parent task ${parentTask.id}`,
);
if (extractTagsTask) {
this.logger.debug(
`Triggered extract_tags task ${extractTagsTask.id} for parent task ${parentTask.id}`,
);
}
} catch (error) {
this.logger.error(
`Failed to trigger extract_tags task for parent task ${parentTask.id}:`,
Expand Down