feat(tasker): expose active comments to agents

This commit is contained in:
DCCONSTRUCTIONS
2026-08-22 00:35:11 +03:00
parent 0df65d85dd
commit 7f97c21886
2 changed files with 166 additions and 1 deletions
@@ -137,6 +137,18 @@ def serialize_comment(comment):
}
def serialize_comment_for_list(comment):
serialized = serialize_comment(comment)
serialized.update(
{
"actor_display_name": comment.actor.display_name if comment.actor else None,
"created_by_id": str(comment.created_by_id) if comment.created_by_id else None,
"updated_by_id": str(comment.updated_by_id) if comment.updated_by_id else None,
}
)
return serialized
def serialize_deleted_comment(comment, deletion_activity=None, include_body=False):
serialized = {
"id": str(comment.id),
@@ -1073,6 +1085,71 @@ class NodeDCAgentIssueMoveEndpoint(View):
@method_decorator(csrf_exempt, name="dispatch")
class NodeDCAgentIssueCommentEndpoint(View):
def get(self, request, issue_id):
error_response = validate_internal_request(request)
if error_response is not None:
return error_response
project_id = request.GET.get("project_id")
if not project_id:
return validation_error("project_id_required")
project, issue = resolve_issue(project_id, issue_id, request.GET.get("workspace_slug"))
if project is None:
return validation_error("project_not_found", status=404)
if issue is None:
return validation_error("issue_not_found", status=404)
project_access_error = validate_agent_project_access(request, project)
if project_access_error is not None:
return project_access_error
limit, error_response = parse_comment_audit_integer(
request,
"limit",
DEFAULT_COMMENT_AUDIT_LIMIT,
1,
MAX_COMMENT_AUDIT_LIMIT,
)
if error_response is not None:
return error_response
offset, error_response = parse_comment_audit_integer(request, "offset", 0, 0, 1_000_000)
if error_response is not None:
return error_response
order = request.GET.get("order", "asc").strip().lower()
if order not in {"asc", "desc"}:
return validation_error("invalid_order")
comments = IssueComment.objects.filter(
project=project,
issue=issue,
deleted_at__isnull=True,
).select_related("actor", "created_by", "updated_by")
comments = comments.order_by(
*(("created_at", "id") if order == "asc" else ("-created_at", "-id"))
)
total_count = comments.count()
page = list(comments[offset : offset + limit])
return JsonResponse(
{
"ok": True,
"project": serialize_project(project),
"issue": {
"id": str(issue.id),
"sequence_id": issue.sequence_id,
"title": issue.name,
},
"comments": [serialize_comment_for_list(comment) for comment in page],
"total_count": total_count,
"offset": offset,
"limit": limit,
"order": order,
"has_more": offset + len(page) < total_count,
}
)
def post(self, request, issue_id):
error_response = validate_internal_request(request)
if error_response is not None: