feat(tickets): Rückfrage am Ticket + Antwort durch die Züchterin

Tickets können jetzt eine Rückfrage (Question) tragen und die Züchterin kann
in-app antworten. Feedback um FK-freie Felder Question/Answer/AnsweredAt erweitert
(überlebt Ingest-Wipe); Status-Lebenszyklus Open → NeedsInfo (Rückfrage gestellt)
→ Answered (beantwortet) → Resolved. Migration AddFeedbackQuestionAnswer.

PUT /feedback/{id}: question → NeedsInfo, answer → Answered+AnsweredAt; DTO gibt
die Felder zurück. Tickets-Seite (/hilfe/tickets) zeigt die Rückfrage hervorgehoben
und bietet ein Antwort-Feld + „Antworten"; Status-Badges Offen/Rückfrage offen/
Beantwortet/Gelöst.

Tests: FeedbackEndpointTests (Frage→NeedsInfo, Antwort→Answered, übersteht Ingest),
e2e tickets.spec.ts. dotnet/vitest/playwright grün.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 19:52:34 +02:00
parent f1c1069821
commit 5069c0eb1e
14 changed files with 2027 additions and 26 deletions

View File

@@ -25,10 +25,18 @@ namespace GerbilManagerWebAPI.Dtos
string? UserAgent,
DateTimeOffset CreatedAt,
string Status,
DateTimeOffset? ResolvedAt);
DateTimeOffset? ResolvedAt,
string? Question,
string? Answer,
DateTimeOffset? AnsweredAt);
/// <summary>FEEDBACK: payload for PUT /feedback/{id} (edit message and/or toggle status).</summary>
/// <summary>
/// FEEDBACK: payload for PUT /feedback/{id}. Edit the message and/or toggle status,
/// attach a clarifying question (Rückfrage), or submit the breeder's answer.
/// </summary>
public record FeedbackUpdate(
string? Message,
string? Status);
string? Status,
string? Question,
string? Answer);
}

View File

@@ -9,7 +9,8 @@ namespace GerbilManagerWebAPI.Endpoints
/// FEEDBACK: the "Fehler melden" report sink + ticket management ("Meine Tickets").
/// POST /feedback -> persist a user bug report (with captured debug context), returns 201.
/// GET /feedback -> list reports, newest first (for the ticket list).
/// PUT /feedback/{id} -> edit the message and/or toggle status Open/Resolved (sets/clears ResolvedAt).
/// PUT /feedback/{id} -> edit message, toggle status, attach a clarifying question (Rückfrage),
/// or submit the breeder's answer. Question -> NeedsInfo; Answer -> Answered + AnsweredAt.
/// DELETE /feedback/{id} -> remove a report. 404 on missing id.
/// Feedback is decoupled from gerbils/litters (loose nullable Guid columns, no FK), so
/// rows survive the import re-ingest wipe.
@@ -71,11 +72,53 @@ namespace GerbilManagerWebAPI.Endpoints
entity.Message = input.Message.Trim();
}
// Attach a clarifying question (Rückfrage). A non-empty question moves the ticket to
// NeedsInfo (waiting on the breeder) unless it is already Resolved. A blank/whitespace
// question clears it.
if (input.Question is not null)
{
var q = input.Question.Trim();
entity.Question = q.Length == 0 ? null : q;
if (entity.Question is not null && !entity.Status.Equals("Resolved", StringComparison.OrdinalIgnoreCase))
{
entity.Status = "NeedsInfo";
entity.ResolvedAt = null;
}
}
// The breeder's answer. A non-empty answer stamps AnsweredAt and moves to Answered.
if (input.Answer is not null)
{
var a = input.Answer.Trim();
if (a.Length == 0)
{
entity.Answer = null;
entity.AnsweredAt = null;
}
else
{
entity.Answer = a;
entity.AnsweredAt = DateTimeOffset.UtcNow;
entity.Status = "Answered";
entity.ResolvedAt = null;
}
}
if (input.Status is not null)
{
// Normalize to the two known states; resolving stamps ResolvedAt, reopening clears it.
var resolved = input.Status.Trim().Equals("Resolved", StringComparison.OrdinalIgnoreCase);
entity.Status = resolved ? "Resolved" : "Open";
// Normalize to a known lifecycle state. Resolving stamps ResolvedAt; any other
// state clears it. Open/NeedsInfo/Answered/Resolved are accepted (case-insensitive),
// anything else falls back to Open.
var status = input.Status.Trim();
var resolved = status.Equals("Resolved", StringComparison.OrdinalIgnoreCase);
var normalized = status switch
{
_ when status.Equals("Resolved", StringComparison.OrdinalIgnoreCase) => "Resolved",
_ when status.Equals("NeedsInfo", StringComparison.OrdinalIgnoreCase) => "NeedsInfo",
_ when status.Equals("Answered", StringComparison.OrdinalIgnoreCase) => "Answered",
_ => "Open",
};
entity.Status = normalized;
entity.ResolvedAt = resolved
? (entity.ResolvedAt ?? DateTimeOffset.UtcNow)
: null;
@@ -102,6 +145,7 @@ namespace GerbilManagerWebAPI.Endpoints
private static FeedbackDto ToDto(Feedback f) =>
new(f.Id, f.Message, f.Context, f.GerbilId, f.LitterId, f.ContactId, f.EntityName, f.Url,
f.ClientTimestamp, f.UserAgent, f.CreatedAt, f.Status, f.ResolvedAt);
f.ClientTimestamp, f.UserAgent, f.CreatedAt, f.Status, f.ResolvedAt,
f.Question, f.Answer, f.AnsweredAt);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GerbilManagerWebAPI.Migrations
{
/// <inheritdoc />
public partial class AddFeedbackQuestionAnswer : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Answer",
table: "Feedback",
type: "text",
nullable: true);
migrationBuilder.AddColumn<DateTimeOffset>(
name: "AnsweredAt",
table: "Feedback",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Question",
table: "Feedback",
type: "text",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Answer",
table: "Feedback");
migrationBuilder.DropColumn(
name: "AnsweredAt",
table: "Feedback");
migrationBuilder.DropColumn(
name: "Question",
table: "Feedback");
}
}
}

View File

@@ -802,6 +802,12 @@ namespace GerbilManagerWebAPI.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Answer")
.HasColumnType("text");
b.Property<DateTimeOffset?>("AnsweredAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("ClientTimestamp")
.HasColumnType("timestamp with time zone");
@@ -828,6 +834,9 @@ namespace GerbilManagerWebAPI.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<string>("Question")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ResolvedAt")
.HasColumnType("timestamp with time zone");

View File

@@ -45,12 +45,23 @@ namespace GerbilManagerWebAPI.Models
public DateTimeOffset CreatedAt { get; set; }
/// <summary>
/// Ticket lifecycle status: "Open" | "Resolved" (default "Open"). Plain string,
/// no FK — keeps feedback decoupled and ingest-surviving like the rest of the row.
/// Ticket lifecycle status: "Open" | "NeedsInfo" | "Answered" | "Resolved" (default "Open").
/// "NeedsInfo" = a maintainer attached a clarifying question (Rückfrage) and is waiting on
/// the breeder; "Answered" = the breeder replied. Plain string, no FK — keeps feedback
/// decoupled and ingest-surviving like the rest of the row.
/// </summary>
public string Status { get; set; } = "Open";
/// <summary>When the ticket was marked resolved; null while open.</summary>
public DateTimeOffset? ResolvedAt { get; set; }
/// <summary>A clarifying question (Rückfrage) a maintainer attaches to the ticket; null if none.</summary>
public string? Question { get; set; }
/// <summary>The breeder's (Züchterin) reply to the clarifying question; null until answered.</summary>
public string? Answer { get; set; }
/// <summary>When the breeder answered the clarifying question; null until answered.</summary>
public DateTimeOffset? AnsweredAt { get; set; }
}
}