bark: each push carries magpie's icon (豆子 on Discord)

A Bark push showed Bark's default icon, so in the notification list it
wasn't clear the push came from magpie. Push now sends Bark's `icon`
field, pointing at https://usemagpie.ai/apple-touch-icon.png: the
app's own 180px apple-touch-icon, copied into site/public and already
deployed (curl: 200 image/png).

Run:
- mote-run go test -count=1 ./internal/bark: ok (the push test now
  checks the icon field).
- gofmt -l internal/bark: clean.

Not tried: a real push to the Bark app on a phone.
This commit is contained in:
yetone
2026-11-17 18:26:56 +08:00
parent 4e977bea9e
commit a9cd746da3
3 changed files with 6 additions and 1 deletions
+5
View File
@@ -51,6 +51,10 @@ func proxied() http.RoundTripper {
// group names the pushes in the Bark app's list.
const group = "magpie"
// icon is magpie's own icon, which the Bark app shows on each push. It is
// the site's copy of the app's apple-touch-icon.
const icon = "https://usemagpie.ai/apple-touch-icon.png"
// Push sends title and body to t. The error names the server's answer,
// never the device key.
func Push(ctx context.Context, t Target, title, body string) error {
@@ -62,6 +66,7 @@ func Push(ctx context.Context, t Target, title, body string) error {
"title": title,
"body": body,
"group": group,
"icon": icon,
})
req, err := http.NewRequestWithContext(ctx, "POST", t.url(), bytes.NewReader(b))
if err != nil {
+1 -1
View File
@@ -49,7 +49,7 @@ func TestPushPostsJSONAndNeverPutsTheKeyInTheAddress(t *testing.T) {
t.Fatalf("requests %v", f.urls)
}
m := f.got[0]
if m["device_key"] != "SECRETKEY123" || m["title"] != "Title" || m["body"] != "Body" || m["group"] != "magpie" {
if m["device_key"] != "SECRETKEY123" || m["title"] != "Title" || m["body"] != "Body" || m["group"] != "magpie" || m["icon"] != "https://usemagpie.ai/apple-touch-icon.png" {
t.Fatalf("body %v", m)
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB