From 519dd9e46f84c71179ea8317f339bfddcbc94c00 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 6 Feb 2026 19:30:03 -0800 Subject: [PATCH] fix notify self, fix superfluous WriteHeader warning --- service/integration/proton/connection.go | 2 +- service/integration/signal/client.go | 10 ++++------ service/integration/signal/link.go | 1 - service/server/middleware.go | 8 +++++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/service/integration/proton/connection.go b/service/integration/proton/connection.go index 61d90ab..228873a 100644 --- a/service/integration/proton/connection.go +++ b/service/integration/proton/connection.go @@ -66,7 +66,7 @@ func (m *Monitor) monitor(ctx context.Context) error { case <-m.newMessagesChan: idleCmd.Close() - m.sendNotification() // Errors already logged in sendNotification() + m.sendNotification() idleCmd, err = m.client.Idle() if err != nil { diff --git a/service/integration/signal/client.go b/service/integration/signal/client.go index 2344087..01a1b6c 100644 --- a/service/integration/signal/client.go +++ b/service/integration/signal/client.go @@ -107,7 +107,6 @@ func (c *Client) GetLinkedAccount() (*Account, error) { return &Account{Number: accounts[0].Number}, nil } -// CreateGroup creates a Signal group using updateGroup JSON-RPC method func (c *Client) CreateGroup(name string) (string, string, error) { if c == nil { return "", "", fmt.Errorf("signal client not initialized") @@ -123,7 +122,7 @@ func (c *Client) CreateGroup(name string) (string, string, error) { params := map[string]interface{}{ "name": name, - "member": []string{}, // Empty group + "member": []string{}, } result, err := c.CallWithAccount("updateGroup", params, account.Number) @@ -145,7 +144,6 @@ func (c *Client) CreateGroup(name string) (string, string, error) { return response.GroupID, account.Number, nil } -// SendGroupMessage sends a message to a Signal group func (c *Client) SendGroupMessage(groupID, message string) error { if c == nil { return fmt.Errorf("signal client not initialized") @@ -160,9 +158,9 @@ func (c *Client) SendGroupMessage(groupID, message string) error { } params := map[string]interface{}{ - "groupId": groupID, - "message": message, - "notify-self": true, + "groupId": groupID, + "message": message, + "notifySelf": true, } _, err = c.CallWithAccount("send", params, account.Number) diff --git a/service/integration/signal/link.go b/service/integration/signal/link.go index 80228a8..7454ead 100644 --- a/service/integration/signal/link.go +++ b/service/integration/signal/link.go @@ -37,7 +37,6 @@ func (l *LinkDevice) GenerateQR() (string, error) { return l.qrCode, nil } - // Call signal-cli's startLink JSON-RPC method directly result, err := l.client.Call("startLink", nil) if err != nil { return "", fmt.Errorf("failed to start link: %w", err) diff --git a/service/server/middleware.go b/service/server/middleware.go index 16a9c66..84ff8b6 100644 --- a/service/server/middleware.go +++ b/service/server/middleware.go @@ -51,14 +51,16 @@ func loggingMiddleware(logger *slog.Logger) func(http.Handler) http.Handler { type responseWriter struct { http.ResponseWriter - statusCode int + statusCode int + headerWritten bool } func (rw *responseWriter) WriteHeader(code int) { - if rw.statusCode == http.StatusOK { + if !rw.headerWritten { rw.statusCode = code + rw.ResponseWriter.WriteHeader(code) + rw.headerWritten = true } - rw.ResponseWriter.WriteHeader(code) } func securityHeadersMiddleware() func(http.Handler) http.Handler {