Skip to content

Commit

Permalink
fix:config name and annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu committed Jun 12, 2024
1 parent cb47d57 commit 9ae653c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 3 additions & 2 deletions config/openim-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ geTui:
channelID: ''
channelName: ''
fcm:
serviceAccount: "x.json"
authUrl: ""
# Prioritize using file paths. If the file path is empty, use URL
serviceAccount: "" # File path is concatenated with the parameters passed in through - c and serviceAccount.
authURL: "" # file URL. Protocol must be specified.
jpns:
appKey: ''
masterSecret: ''
Expand Down
7 changes: 1 addition & 6 deletions internal/push/offlinepush/fcm/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,14 @@ type Fcm struct {
// NewClient initializes a new FCM client using the Firebase Admin SDK.
// It requires the FCM service account credentials file located within the project's configuration directory.
func NewClient(pushConf *config.Push, cache cache.ThirdCache, fcmConfigPath string) (*Fcm, error) {
//projectRoot, err := config.GetProjectRoot()
//if err != nil {
// return nil, err
//}
var opt option.ClientOption
switch {
case len(pushConf.FCM.ServiceAccount) != 0:
// with file path
credentialsFilePath := filepath.Join(fcmConfigPath, pushConf.FCM.ServiceAccount)
opt = option.WithCredentialsFile(credentialsFilePath)
case len(pushConf.FCM.AuthUrl) != 0:
// with authentication url
// with authentication URL
client := httputil.NewHTTPClient(httputil.NewClientConfig())
resp, err := client.Get(pushConf.FCM.AuthUrl)
if err != nil {
Expand All @@ -73,7 +69,6 @@ func NewClient(pushConf *config.Push, cache cache.ThirdCache, fcmConfigPath stri
if err != nil {
return nil, errs.Wrap(err)
}

return &Fcm{fcmMsgCli: fcmMsgClient, cache: cache}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ type Push struct {
} `mapstructure:"geTui"`
FCM struct {
ServiceAccount string `mapstructure:"serviceAccount"`
AuthUrl string `mapstructure:"authUrl"`
AuthUrl string `mapstructure:"authURL"`
} `mapstructure:"fcm"`
JPNS struct {
AppKey string `mapstructure:"appKey"`
Expand Down

0 comments on commit 9ae653c

Please sign in to comment.