Skip to content

Commit

Permalink
Merge pull request #72 from kayac/drop-fcm-legacy
Browse files Browse the repository at this point in the history
remove regacy fcm
  • Loading branch information
fujiwara authored Apr 5, 2024
2 parents 8742f00 + ab02a9e commit ab7387c
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 574 deletions.
29 changes: 3 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,11 @@ Response example:
{"result": "ok"}
```

### POST /push/fcm
### POST /push/fcm **Deprecated**

To delivery remote notifications via FCM (legacy) API to user's devices.
This API has been deleted at v0.6.0. Use `/push/fcm/v1` instead.

Post body format is equal to it for FCM legacy origin server.

example:
```json
{
"registration_ids": [
"token1",
"token2"
],
"data": {
"id": "2",
"message": "Test2"
},
"notification": {
"title": "message_title",
"body": "message_body"
}
}
```

Response example:
```json
{"result": "ok"}
```
See also https://firebase.google.com/docs/cloud-messaging/migrate-v1 .

### POST /push/fcm/v1

Expand Down
8 changes: 4 additions & 4 deletions apns/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"time"

"github.com/kayac/Gunfish/config"
Expand Down Expand Up @@ -151,12 +151,12 @@ func NewClient(conf config.SectionApns) (*Client, error) {
useAuthToken := conf.Kid != "" && conf.TeamID != ""
tr := &http.Transport{}
if !useAuthToken {
certPEMBlock, err := ioutil.ReadFile(conf.CertFile)
certPEMBlock, err := os.ReadFile(conf.CertFile)
if err != nil {
return nil, err
}

keyPEMBlock, err := ioutil.ReadFile(conf.KeyFile)
keyPEMBlock, err := os.ReadFile(conf.KeyFile)
if err != nil {
return nil, err
}
Expand All @@ -172,7 +172,7 @@ func NewClient(conf config.SectionApns) (*Client, error) {
return nil, err
}

key, err := ioutil.ReadFile(conf.KeyFile)
key, err := os.ReadFile(conf.KeyFile)
if err != nil {
return nil, err
}
Expand Down
13 changes: 3 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/x509"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"time"

"github.com/kayac/Gunfish/fcmv1"
Expand Down Expand Up @@ -125,10 +125,7 @@ func (c *Config) validateConfig() error {
}
}
if c.FCM.APIKey != "" {
c.FCM.Enabled = true
if err := c.validateConfigFCM(); err != nil {
return errors.Wrap(err, "[fcm]")
}
return errors.New("[fcm] legacy is not supported anymore. Please use [fcm_v1]")
}
if c.FCMv1.GoogleApplicationCredentials != "" {
c.FCMv1.Enabled = true
Expand Down Expand Up @@ -158,12 +155,8 @@ func (c *Config) validateConfigProvider() error {
return nil
}

func (c *Config) validateConfigFCM() error {
return nil
}

func (c *Config) validateConfigFCMv1() error {
b, err := ioutil.ReadFile(c.FCMv1.GoogleApplicationCredentials)
b, err := os.ReadFile(c.FCMv1.GoogleApplicationCredentials)
if err != nil {
return err
}
Expand Down
104 changes: 0 additions & 104 deletions fcm/client.go

This file was deleted.

50 changes: 0 additions & 50 deletions fcm/error.go

This file was deleted.

16 changes: 0 additions & 16 deletions fcm/fcmerrorresponsecode_string.go

This file was deleted.

35 changes: 0 additions & 35 deletions fcm/request.go

This file was deleted.

71 changes: 0 additions & 71 deletions fcm/request_test.go

This file was deleted.

Loading

0 comments on commit ab7387c

Please sign in to comment.