From 8bbe3d3cb38c6ee6e3f82be1db51acba5b1ca909 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 10 Mar 2026 04:58:24 +0000 Subject: [PATCH] Add simple history log to communications --- api/communication.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/api/communication.go b/api/communication.go index b92579bd..ab8d84e9 100644 --- a/api/communication.go +++ b/api/communication.go @@ -14,6 +14,10 @@ import ( //"github.com/rs/zerolog/log" ) +type historyEntry struct { + Action string `json:"action"` + Timestamp time.Time `json:"timestamp"` +} type reporter struct { HasEmail bool `json:"has_email"` HasPhone bool `json:"has_phone"` @@ -21,6 +25,7 @@ type reporter struct { } type communication struct { Created time.Time `json:"created"` + History []historyEntry `json:"history"` ID string `json:"id"` PublicReport types.PublicReport `json:"public_report"` Type string `json:"type"` @@ -41,7 +46,13 @@ func listCommunication(ctx context.Context, r *http.Request, org *models.Organiz comms := make([]communication, len(nreports)+len(wreports)) for i, report := range nreports { comms[i] = communication{ - Created: report.Created, + Created: report.Created, + History: []historyEntry{ + historyEntry{ + Action: "created", + Timestamp: report.Created, + }, + }, ID: report.PublicID, PublicReport: report, Type: "nuisance", @@ -49,7 +60,13 @@ func listCommunication(ctx context.Context, r *http.Request, org *models.Organiz } for i, report := range wreports { comms[i+len(nreports)] = communication{ - Created: report.Created, + Created: report.Created, + History: []historyEntry{ + historyEntry{ + Action: "created", + Timestamp: report.Created, + }, + }, ID: report.PublicID, PublicReport: report, Type: "water",