Skip to content

Commit

Permalink
Migrate to FCM HTTP v1 API
Browse files Browse the repository at this point in the history
The current API is deprecated and will be turned off in June 2024.
  • Loading branch information
moffatman authored and karmanyaahm committed May 6, 2024
1 parent f2b8305 commit a96f772
Show file tree
Hide file tree
Showing 6 changed files with 1,684 additions and 60 deletions.
34 changes: 17 additions & 17 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

See [the example configuration file](../example-config.toml) for how a toml configuration should be arranged.

| Description | TOML Name | Environment Variable Name | Type | More Info |
| :---: | --- | --- | --- | --- |
| HTTP Listener Address | listenAddr | UP_LISTEN | string | This doesn't have any effect inside docker. |
| Verbose logs | verbose | UP_VERBOSE | boolean | Detailed logs or not. It is recommended to always set this to true. |
| Gateway User Agent | UserAgentID | UP_UAID | string | A user agent comment for gateway forwarded requests. Useful for debugging (and rate limits for big gateways). Example: "matrix.gateway.unifiedpush.org by unifiedpush.org" |
| Enable Matrix Gateway | gateway.matrix.enable | UP_GATEWAY_MATRIX_ENABLE | boolean | |
| Enable Gotify Rewrite Proxy | rewrite.gotify.enable | UP_REWRITE_GOTIFY_ENABLE | boolean | |
| Gotify forwarding address | rewrite.gotify.address | UP_REWRITE_GOTIFY_ADDRESS | string | What is the domain of your Gotify server. This has to be a `host:port` or `host` if you want the default port for the scheme. |
| Gotify forwarding scheme | rewrite.gotify.scheme | UP_REWRITE_GOTIFY_SCHEME | string | `http` or `https` |
| Enable FCM Rewrite Proxy | rewrite.fcm.enable | UP_REWRITE_FCM_ENABLE | boolean | |
| Firebase Server Key for FCM | rewrite.fcm.key | UP_REWRITE_FCM_KEY | string | An FCM request to any hostname will be forwarded with this key. Not recommended, use per hostname keys if possible. |
| Firebase Server Keys per hostname | rewrite.fcm.Keys | none | map[hostname] = key | Specify the hostname that will be receiving requests and the key that request should be forwarded to. |
| Allowed Gateway Hosts | gateway.AllowedHosts | UP_GATEWAY_ALLOWEDHOSTS | string list | See relevant section below |

## FCM Keys

See <https://unifiedpush.org/developers/embedded_fcm/#firebase-setup> for more info on how to set up FCM keys properly.
| Description | TOML Name | Environment Variable Name | Type | More Info |
| :---: | --- | --- | --- | --- |
| HTTP Listener Address | listenAddr | UP_LISTEN | string | This doesn't have any effect inside docker. |
| Verbose logs | verbose | UP_VERBOSE | boolean | Detailed logs or not. It is recommended to always set this to true. |
| Gateway User Agent | UserAgentID | UP_UAID | string | A user agent comment for gateway forwarded requests. Useful for debugging (and rate limits for big gateways). Example: "matrix.gateway.unifiedpush.org by unifiedpush.org" |
| Enable Matrix Gateway | gateway.matrix.enable | UP_GATEWAY_MATRIX_ENABLE | boolean | |
| Enable Gotify Rewrite Proxy | rewrite.gotify.enable | UP_REWRITE_GOTIFY_ENABLE | boolean | |
| Gotify forwarding address | rewrite.gotify.address | UP_REWRITE_GOTIFY_ADDRESS | string | What is the domain of your Gotify server. This has to be a `host:port` or `host` if you want the default port for the scheme. |
| Gotify forwarding scheme | rewrite.gotify.scheme | UP_REWRITE_GOTIFY_SCHEME | string | `http` or `https` |
| Enable FCM Rewrite Proxy | rewrite.fcm.enable | UP_REWRITE_FCM_ENABLE | boolean | |
| Firebase Credentials for FCM | rewrite.fcm.credentialsPath | UP_REWRITE_FCM_CREDENTIALS_PATH | string | An FCM request to any hostname will be forwarded with credentials loaded from this path. Not recommended, use per hostname credentials if possible. |
| Firebase Credentials per hostname | rewrite.fcm.CredentialsPaths | none | map[hostname] = path | Specify the hostname that will be receiving requests and the credentials path that request should be forwarded with. |
| Allowed Gateway Hosts | gateway.AllowedHosts | UP_GATEWAY_ALLOWEDHOSTS | string list | See relevant section below |

## FCM Credentials

See <https://unifiedpush.org/developers/embedded_fcm/#firebase-setup> for more info on how to set up FCM credentials properly.

## Gateway Allowed Hosts

Expand Down
8 changes: 4 additions & 4 deletions example-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ verbose = true
[rewrite]
[rewrite.fcm]
enabled = false
# key = "" # key for any hostname
[rewrite.fcm.Keys] # keys for specific hostnames
#"your.fcm.hostname.example.org" = "YOUR_FCM_KEY"
#"other.fcm.hostname.example.org" = "OTHER_FCM_KEY"
# credentialsPath = "" # credentials json path for any hostname
[rewrite.fcm.CredentialsPaths] # keys for specific hostnames
#"your.fcm.hostname.example.org" = "/path/to/your-service-account-file.json"
#"other.fcm.hostname.example.org" = "/path/to/other-service-account-file.json"
[rewrite.gotify]
enabled = false
#address = "gotify1.unifiedpush.org:443"
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ require (
github.com/hakobe/paranoidhttp v0.2.0
github.com/komkom/toml v0.0.0-20210317065440-24f427ca88cc
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
golang.org/x/oauth2 v0.19.0
)

replace github.com/hakobe/paranoidhttp => github.com/karmanyaahm/paranoidhttp v0.2.1-0.20210628044206-c40d6edc4d56
Loading

0 comments on commit a96f772

Please sign in to comment.