Skip to content

Commit

Permalink
Add HTTP v1 Firebase API client (#4387)
Browse files Browse the repository at this point in the history
The Firebase API used by the stack has been deprecated and will soon be
removed. This commit adds a way to use the new HTTP v1 API.

https://firebase.google.com/docs/cloud-messaging/migrate-v1
  • Loading branch information
nono authored Apr 30, 2024
2 parents 2b5c3af + 2df9c64 commit a7c217f
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 29 deletions.
6 changes: 2 additions & 4 deletions cozy.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,8 @@ notifications:
# Activate development APIs (iOS only)
development: false

# Firebase Cloud Messaging API Key for Android notifications
# android_api_key: ""
# Use this key to run end to test with a fake FCM server
# fcm_server: "http://localhost:3001"
# Firebase Cloud Messaging API
fcm_credentials_file: /etc/cozy/fcm_credentials.json

# APNS/2 certificates for iOS notifications
# ios_certificate_key_path: path/to/certificate.p12
Expand Down
12 changes: 6 additions & 6 deletions docs/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ sent.

The push notifications can be sent via Firebase to smartphones. By default, the
key used to connect to firebase is set in the configuration file, via the
`notifications.android_api_key` parameter. But it can be useful to have several
firebase accounts when there are several applications developed by several
organizations. In that case, it is possible to tell the stack to use a particular
key for a given app by creating a CouchDB document inside the
`notifications.fcm_credentials_file` parameter. But it can be useful to have
several firebase accounts when there are several applications developed by
several organizations. In that case, it is possible to tell the stack to use a
particular key for a given app by creating a CouchDB document inside the
`secrets/io-cozy-account_types` database, like this:

```json
{
"_id": "myapp",
"slug": "myapp",
"android_api_key": "th3_f1r3b4s3_k3y"
"fcm_credentials": {"type": "service_account", "etc.": "..."}
}
```

Expand All @@ -36,7 +36,7 @@ with the context name and `/`:
{
"_id": "mycontext/myapp",
"slug": "myapp",
"android_api_key": "th3_0th3r_f1r3b4s3_k3y"
"fcm_credentials": {"type": "service_account", "etc.": "..."}
}
```

Expand Down
32 changes: 31 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ require (
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/firestore v1.15.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
cloud.google.com/go/longrunning v0.5.5 // indirect
cloud.google.com/go/storage v1.40.0 // indirect
firebase.google.com/go/v4 v4.14.0 // indirect
github.com/MicahParks/keyfunc v1.9.0 // indirect
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -66,11 +75,20 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
Expand Down Expand Up @@ -110,12 +128,24 @@ require (
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/api v0.170.0 // indirect
google.golang.org/appengine/v2 v2.0.2 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit a7c217f

Please sign in to comment.