merge: make add_task optional params actually optional

This commit is contained in:
Mika Kuns
2026-06-01 15:29:29 +02:00

View File

@@ -90,17 +90,15 @@ public sealed class ExternalMcpService
public async Task<TaskDto> AddTask( public async Task<TaskDto> AddTask(
string listId, string listId,
string title, string title,
string? description, string? description = null,
string createdBy, string? createdBy = null,
bool queueImmediately, bool queueImmediately = false,
CancellationToken cancellationToken) CancellationToken cancellationToken = default)
{ {
if (string.IsNullOrWhiteSpace(listId)) if (string.IsNullOrWhiteSpace(listId))
throw new InvalidOperationException("listId is required."); throw new InvalidOperationException("listId is required.");
if (string.IsNullOrWhiteSpace(title)) if (string.IsNullOrWhiteSpace(title))
throw new InvalidOperationException("title is required."); throw new InvalidOperationException("title is required.");
if (string.IsNullOrWhiteSpace(createdBy))
throw new InvalidOperationException("createdBy is required.");
var list = await _lists.GetByIdAsync(listId, cancellationToken) var list = await _lists.GetByIdAsync(listId, cancellationToken)
?? throw new InvalidOperationException($"List {listId} not found."); ?? throw new InvalidOperationException($"List {listId} not found.");
@@ -114,7 +112,7 @@ public sealed class ExternalMcpService
Status = TaskStatus.Idle, Status = TaskStatus.Idle,
CreatedAt = DateTime.UtcNow, CreatedAt = DateTime.UtcNow,
CommitType = list.DefaultCommitType, CommitType = list.DefaultCommitType,
CreatedBy = createdBy, CreatedBy = createdBy.NullIfBlank() ?? "mcp",
}; };
await _tasks.AddAsync(entity, cancellationToken); await _tasks.AddAsync(entity, cancellationToken);