From cf522ceb0afc6299b3d2aef99f88301ab7642b6d Mon Sep 17 00:00:00 2001 From: Rodrigo Verdiani Date: Tue, 7 Jul 2026 09:09:50 -0300 Subject: [PATCH] fix(ntfy): use integer for priority field in JSON payload --- docs/blueprints/10-ntfy-notifications.md | 2 +- internal/ntfy/client.go | 6 +++--- internal/ntfy/client_test.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/blueprints/10-ntfy-notifications.md b/docs/blueprints/10-ntfy-notifications.md index 84a8133..cdb9a26 100644 --- a/docs/blueprints/10-ntfy-notifications.md +++ b/docs/blueprints/10-ntfy-notifications.md @@ -44,7 +44,7 @@ func (c *Client) Notify(ctx context.Context, job *models.Job) error ``` - Endpoint: `POST {NtfyURL}/{NtfyTopic}` -- Prioridade: `high` para erro, `default` para sucesso. +- Prioridade: `4` (high) para erro, `3` (default) para sucesso. - Tags: `white_check_mark` (done), `x` (error). - Corpo: `json.Marshal(ntfyMessage{...})` com title, message, priority, tags. - Header `Authorization: Bearer ` apenas se token != "". diff --git a/internal/ntfy/client.go b/internal/ntfy/client.go index fdf6609..15f399c 100644 --- a/internal/ntfy/client.go +++ b/internal/ntfy/client.go @@ -24,7 +24,7 @@ type payload struct { Topic string `json:"topic"` Title string `json:"title"` Message string `json:"message"` - Priority string `json:"priority"` + Priority int `json:"priority"` Tags []string `json:"tags"` } @@ -104,7 +104,7 @@ func buildPayload(topic string, job *models.Job) payload { Topic: topic, Title: fmt.Sprintf("Coda: %s - %s failed", job.Artist, job.Album), Message: job.ErrorMsg, - Priority: "high", + Priority: 4, Tags: []string{"x"}, } } @@ -112,7 +112,7 @@ func buildPayload(topic string, job *models.Job) payload { Topic: topic, Title: fmt.Sprintf("Coda: %s - %s completed", job.Artist, job.Album), Message: "Conversion completed successfully", - Priority: "default", + Priority: 3, Tags: []string{"white_check_mark"}, } } diff --git a/internal/ntfy/client_test.go b/internal/ntfy/client_test.go index 3f6a11c..ee2c2a8 100644 --- a/internal/ntfy/client_test.go +++ b/internal/ntfy/client_test.go @@ -117,8 +117,8 @@ func TestNotifySendsDoneMessage(t *testing.T) { if gotPayload.Message != "Conversion completed successfully" { t.Errorf("message = %q, want success message", gotPayload.Message) } - if gotPayload.Priority != "default" { - t.Errorf("priority = %q, want default", gotPayload.Priority) + if gotPayload.Priority != 3 { + t.Errorf("priority = %d, want 3", gotPayload.Priority) } if len(gotPayload.Tags) != 1 || gotPayload.Tags[0] != "white_check_mark" { t.Errorf("tags = %v, want [white_check_mark]", gotPayload.Tags) @@ -158,8 +158,8 @@ func TestNotifySendsErrorMessage(t *testing.T) { if gotPayload.Message != "validation failed" { t.Errorf("message = %q, want error message", gotPayload.Message) } - if gotPayload.Priority != "high" { - t.Errorf("priority = %q, want high", gotPayload.Priority) + if gotPayload.Priority != 4 { + t.Errorf("priority = %d, want 4", gotPayload.Priority) } if len(gotPayload.Tags) != 1 || gotPayload.Tags[0] != "x" { t.Errorf("tags = %v, want [x]", gotPayload.Tags)