From 50f6de2f6c8b05193d0ca3f3881bd662b4babe60 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 12 May 2025 14:34:19 +0200 Subject: syz-cluster: add reply tracking functionality Add API to record replies under the reports that allows to determine the original report only by having the MessageID. --- syz-cluster/pkg/api/reporter.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'syz-cluster/pkg/api') diff --git a/syz-cluster/pkg/api/reporter.go b/syz-cluster/pkg/api/reporter.go index 5a7b7bfb4..e73bdb668 100644 --- a/syz-cluster/pkg/api/reporter.go +++ b/syz-cluster/pkg/api/reporter.go @@ -7,6 +7,7 @@ import ( "context" "net/url" "strings" + "time" ) type ReporterClient struct { @@ -53,3 +54,30 @@ func (client ReporterClient) UpstreamReport(ctx context.Context, id string, req _, err := postJSON[UpstreamReportReq, any](ctx, client.baseURL+"/reports/"+id+"/upstream", req) return err } + +type RecordReplyReq struct { + MessageID string `json:"message_id"` + InReplyTo string `json:"in_reply_to"` + Reporter string `json:"reporter"` + Time time.Time `json:"time"` +} + +type RecordReplyResp struct { + New bool `json:"new"` + ReportID string `json:"report_id"` // or empty, if no original message was found +} + +func (client ReporterClient) RecordReply(ctx context.Context, req *RecordReplyReq) (*RecordReplyResp, error) { + return postJSON[RecordReplyReq, RecordReplyResp](ctx, client.baseURL+"/reports/record_reply", req) +} + +type LastReplyResp struct { + Time time.Time `json:"time"` +} + +// Returns nil if no reply has ever been recorded. +func (client ReporterClient) LastReply(ctx context.Context, reporter string) (*LastReplyResp, error) { + v := url.Values{} + v.Add("reporter", reporter) + return postJSON[any, LastReplyResp](ctx, client.baseURL+"/reports/last_reply?"+v.Encode(), nil) +} -- cgit mrf-deployment