fix(ntfy): use integer for priority field in JSON payload
This commit is contained in:
parent
e554149e8b
commit
cf522ceb0a
@ -44,7 +44,7 @@ func (c *Client) Notify(ctx context.Context, job *models.Job) error
|
|||||||
```
|
```
|
||||||
|
|
||||||
- Endpoint: `POST {NtfyURL}/{NtfyTopic}`
|
- 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).
|
- Tags: `white_check_mark` (done), `x` (error).
|
||||||
- Corpo: `json.Marshal(ntfyMessage{...})` com title, message, priority, tags.
|
- Corpo: `json.Marshal(ntfyMessage{...})` com title, message, priority, tags.
|
||||||
- Header `Authorization: Bearer <NtfyToken>` apenas se token != "".
|
- Header `Authorization: Bearer <NtfyToken>` apenas se token != "".
|
||||||
|
|||||||
@ -24,7 +24,7 @@ type payload struct {
|
|||||||
Topic string `json:"topic"`
|
Topic string `json:"topic"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Priority string `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ func buildPayload(topic string, job *models.Job) payload {
|
|||||||
Topic: topic,
|
Topic: topic,
|
||||||
Title: fmt.Sprintf("Coda: %s - %s failed", job.Artist, job.Album),
|
Title: fmt.Sprintf("Coda: %s - %s failed", job.Artist, job.Album),
|
||||||
Message: job.ErrorMsg,
|
Message: job.ErrorMsg,
|
||||||
Priority: "high",
|
Priority: 4,
|
||||||
Tags: []string{"x"},
|
Tags: []string{"x"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func buildPayload(topic string, job *models.Job) payload {
|
|||||||
Topic: topic,
|
Topic: topic,
|
||||||
Title: fmt.Sprintf("Coda: %s - %s completed", job.Artist, job.Album),
|
Title: fmt.Sprintf("Coda: %s - %s completed", job.Artist, job.Album),
|
||||||
Message: "Conversion completed successfully",
|
Message: "Conversion completed successfully",
|
||||||
Priority: "default",
|
Priority: 3,
|
||||||
Tags: []string{"white_check_mark"},
|
Tags: []string{"white_check_mark"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,8 +117,8 @@ func TestNotifySendsDoneMessage(t *testing.T) {
|
|||||||
if gotPayload.Message != "Conversion completed successfully" {
|
if gotPayload.Message != "Conversion completed successfully" {
|
||||||
t.Errorf("message = %q, want success message", gotPayload.Message)
|
t.Errorf("message = %q, want success message", gotPayload.Message)
|
||||||
}
|
}
|
||||||
if gotPayload.Priority != "default" {
|
if gotPayload.Priority != 3 {
|
||||||
t.Errorf("priority = %q, want default", gotPayload.Priority)
|
t.Errorf("priority = %d, want 3", gotPayload.Priority)
|
||||||
}
|
}
|
||||||
if len(gotPayload.Tags) != 1 || gotPayload.Tags[0] != "white_check_mark" {
|
if len(gotPayload.Tags) != 1 || gotPayload.Tags[0] != "white_check_mark" {
|
||||||
t.Errorf("tags = %v, want [white_check_mark]", gotPayload.Tags)
|
t.Errorf("tags = %v, want [white_check_mark]", gotPayload.Tags)
|
||||||
@ -158,8 +158,8 @@ func TestNotifySendsErrorMessage(t *testing.T) {
|
|||||||
if gotPayload.Message != "validation failed" {
|
if gotPayload.Message != "validation failed" {
|
||||||
t.Errorf("message = %q, want error message", gotPayload.Message)
|
t.Errorf("message = %q, want error message", gotPayload.Message)
|
||||||
}
|
}
|
||||||
if gotPayload.Priority != "high" {
|
if gotPayload.Priority != 4 {
|
||||||
t.Errorf("priority = %q, want high", gotPayload.Priority)
|
t.Errorf("priority = %d, want 4", gotPayload.Priority)
|
||||||
}
|
}
|
||||||
if len(gotPayload.Tags) != 1 || gotPayload.Tags[0] != "x" {
|
if len(gotPayload.Tags) != 1 || gotPayload.Tags[0] != "x" {
|
||||||
t.Errorf("tags = %v, want [x]", gotPayload.Tags)
|
t.Errorf("tags = %v, want [x]", gotPayload.Tags)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user