fix: improve conversation and report stability

This commit is contained in:
richjohnrambo
2026-08-26 14:12:58 +08:00
parent dc80aa5104
commit a0fc553c6f
6 changed files with 138 additions and 14 deletions
+20 -8
View File
@@ -68,6 +68,7 @@ const (
imQRCodeMaxExpiresInSeconds = 7 * 86400
imPublicUploadMaxBytes = 10 << 20
groupMaxAdminCount = 10
monthlyReportPreviewMaxRunes = 120
)
type imHTTPResponse struct {
@@ -7206,14 +7207,16 @@ func monthlyReportListPayload(report types.MonthlyReport) map[string]any {
action = "edit"
}
data := map[string]any{
"report_id": report.ReportID,
"author_id": report.AuthorID.UserId(),
"month": report.Month,
"status": report.Status,
"read_state": report.ReadState,
"version": report.Version,
"action": action,
"updated_at": report.UpdatedAt.UTC().Format(time.RFC3339Nano),
"report_id": report.ReportID,
"author_id": report.AuthorID.UserId(),
"month": report.Month,
"work_summary_short": monthlyReportPreview(report.WorkSummary),
"next_plan_short": monthlyReportPreview(report.NextPlan),
"status": report.Status,
"read_state": report.ReadState,
"version": report.Version,
"action": action,
"updated_at": report.UpdatedAt.UTC().Format(time.RFC3339Nano),
}
if report.SubmittedAt != nil {
data["submitted_at"] = report.SubmittedAt.UTC().Format(time.RFC3339Nano)
@@ -7221,6 +7224,15 @@ func monthlyReportListPayload(report types.MonthlyReport) map[string]any {
return data
}
func monthlyReportPreview(text string) string {
text = strings.Join(strings.Fields(text), " ")
runes := []rune(text)
if len(runes) <= monthlyReportPreviewMaxRunes {
return text
}
return string(runes[:monthlyReportPreviewMaxRunes]) + "..."
}
func monthlyReportDetailPayload(report *types.MonthlyReport, viewer types.Uid) map[string]any {
data := monthlyReportListPayload(*report)
data["work_summary"] = report.WorkSummary