diff --git a/config/openim-push.yml b/config/openim-push.yml index d09c664c5..63cba053d 100644 --- a/config/openim-push.yml +++ b/config/openim-push.yml @@ -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: '' diff --git a/internal/push/offlinepush/fcm/push.go b/internal/push/offlinepush/fcm/push.go index 4924cf5a9..515f0ab9a 100644 --- a/internal/push/offlinepush/fcm/push.go +++ b/internal/push/offlinepush/fcm/push.go @@ -42,10 +42,6 @@ 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: @@ -53,7 +49,7 @@ func NewClient(pushConf *config.Push, cache cache.ThirdCache, fcmConfigPath stri 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 { @@ -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 } diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index bd44c38f3..cc5c3a9c5 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -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"`