]> cat aescling's git repositories - mastodon.git/commit
Improve payload format of Web Push API now that it's open (#7521)
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 19 May 2018 12:46:47 +0000 (14:46 +0200)
committerGitHub <noreply@github.com>
Sat, 19 May 2018 12:46:47 +0000 (14:46 +0200)
commit4b94e9c65efd227c58f8be9b3db6b667d403ed3c
tree32c3e4f22fa78fb6d74062e192ea8cc7c59f135b
parent1951ff41b33b264fd8179998648c3cbbf2834cd5
Improve payload format of Web Push API now that it's open (#7521)

> Good lord what is happening in there

Previously the contents of the Web Push API payloads closely resembled the structure of JavaScript's [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification). But now that the API is open to non-browser apps, and given that there is no required coupling between contents of the payload and a Notification object, here is how I changed the payload:

```json
{
  "access_token": "...",
  "preferred_locale": "en",
  "notification_id": "12345",
  "notification_type": "follow",
  "title": "So and so followed you",
  "body": "This is my bio",
  "icon": "https://example.com/avatar.png"
}
```

The title, body and icon attributes are included as a fallback so you can construct a minimal notification if you cannot perform a network request to the API to get more data.
76 files changed:
app/javascript/mastodon/actions/notifications.js
app/javascript/mastodon/locales/ar.json
app/javascript/mastodon/locales/bg.json
app/javascript/mastodon/locales/ca.json
app/javascript/mastodon/locales/co.json
app/javascript/mastodon/locales/de.json
app/javascript/mastodon/locales/defaultMessages.json
app/javascript/mastodon/locales/el.json
app/javascript/mastodon/locales/en.json
app/javascript/mastodon/locales/eo.json
app/javascript/mastodon/locales/es.json
app/javascript/mastodon/locales/eu.json
app/javascript/mastodon/locales/fa.json
app/javascript/mastodon/locales/fi.json
app/javascript/mastodon/locales/fr.json
app/javascript/mastodon/locales/gl.json
app/javascript/mastodon/locales/he.json
app/javascript/mastodon/locales/hr.json
app/javascript/mastodon/locales/hu.json
app/javascript/mastodon/locales/hy.json
app/javascript/mastodon/locales/id.json
app/javascript/mastodon/locales/io.json
app/javascript/mastodon/locales/it.json
app/javascript/mastodon/locales/ja.json
app/javascript/mastodon/locales/ko.json
app/javascript/mastodon/locales/nl.json
app/javascript/mastodon/locales/no.json
app/javascript/mastodon/locales/oc.json
app/javascript/mastodon/locales/pl.json
app/javascript/mastodon/locales/pt-BR.json
app/javascript/mastodon/locales/pt.json
app/javascript/mastodon/locales/ru.json
app/javascript/mastodon/locales/sk.json
app/javascript/mastodon/locales/sl.json
app/javascript/mastodon/locales/sr-Latn.json
app/javascript/mastodon/locales/sr.json
app/javascript/mastodon/locales/sv.json
app/javascript/mastodon/locales/te.json
app/javascript/mastodon/locales/th.json
app/javascript/mastodon/locales/tr.json
app/javascript/mastodon/locales/uk.json
app/javascript/mastodon/locales/zh-CN.json
app/javascript/mastodon/locales/zh-HK.json
app/javascript/mastodon/locales/zh-TW.json
app/javascript/mastodon/service_worker/web_push_locales.js [new file with mode: 0644]
app/javascript/mastodon/service_worker/web_push_notifications.js
app/models/web/push_subscription.rb
app/serializers/web/notification_serializer.rb
config/locales/ar.yml
config/locales/ca.yml
config/locales/co.yml
config/locales/de.yml
config/locales/en.yml
config/locales/eo.yml
config/locales/es.yml
config/locales/fa.yml
config/locales/fi.yml
config/locales/fr.yml
config/locales/gl.yml
config/locales/hu.yml
config/locales/it.yml
config/locales/ja.yml
config/locales/ko.yml
config/locales/nl.yml
config/locales/no.yml
config/locales/oc.yml
config/locales/pl.yml
config/locales/pt-BR.yml
config/locales/pt.yml
config/locales/ru.yml
config/locales/sk.yml
config/locales/sr-Latn.yml
config/locales/sr.yml
config/locales/sv.yml
config/locales/zh-CN.yml
config/locales/zh-HK.yml