Loading pkg/iap/apple.go +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ func NewAppleClientWithHTTP(password string, production bool, httpClient *http.C func (ac *AppleClient) init(production bool) error { if ac.password == "" { return errors.New("Apple in-app purchase configuration is inactive. Reason: Missing password.") return errors.New("Missing password.") } return nil Loading pkg/iap/google.go +5 −5 Original line number Diff line number Diff line Loading @@ -48,20 +48,20 @@ func NewGoogleClient(packageName string, serviceKeyFilePath string, timeout int) } if gc.packageName == "" { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Missing package name.") return nil, errors.New("Missing package name.") } if gc.serviceKeyFilePath == "" { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Missing service account key.") return nil, errors.New("Missing service account key.") } jsonContent, err := ioutil.ReadFile(gc.serviceKeyFilePath) if err != nil { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Failed to read Google service account key.") return nil, errors.New("Failed to read Google service account key.") } config, err := google.JWTConfigFromJSON(jsonContent, GOOGLE_IAP_SCOPE) if err != nil { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Failed to parse Google service account key.") return nil, errors.New("Failed to parse Google service account key.") } gc.client = config.Client(context.Background()) Loading @@ -71,7 +71,7 @@ func NewGoogleClient(packageName string, serviceKeyFilePath string, timeout int) func NewGoogleClientWithHTTP(packageName string, httpClient *http.Client) (*GoogleClient, error) { if packageName == "" { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Missing package name.") return nil, errors.New("Missing package name.") } gc := &GoogleClient{ Loading server/core_purchase.go +2 −2 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ type PurchaseService struct { func NewPurchaseService(jsonLogger *zap.Logger, multiLogger *zap.Logger, db *sql.DB, config *PurchaseConfig) *PurchaseService { ac, err := iap.NewAppleClient(config.Apple.Password, config.Apple.Production, config.Apple.TimeoutMs) if err != nil { multiLogger.Warn("Skip initialising Apple in-app purchase provider", zap.Error(err)) multiLogger.Warn("Skip initialising Apple in-app purchase provider", zap.String("reason,", err.Error())) } else { if config.Apple.Production { multiLogger.Info("Apple in-app purchase environment is set to Production priority.") Loading @@ -48,7 +48,7 @@ func NewPurchaseService(jsonLogger *zap.Logger, multiLogger *zap.Logger, db *sql gc, err := iap.NewGoogleClient(config.Google.PackageName, config.Google.ServiceKeyFilePath, config.Google.TimeoutMs) if err != nil { multiLogger.Warn("Skip initialising Google in-app purchase provider", zap.Error(err)) multiLogger.Warn("Skip initialising Google in-app purchase provider", zap.String("reason", err.Error())) } return &PurchaseService{ Loading tests/modules/notification.lua 0 → 100644 +32 −0 Original line number Diff line number Diff line --[[ Copyright 2017 The Nakama Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --]] local nk = require("nakama") local nx = require("nakamax") function notification_send(ctx, payload) notifications = { { Subject="test_notification",Content='{"hello": "world"}',UserId=ctx["user_id"],Code=101,Persistent=true }, } local status, res = pcall(nk.notifications_send_id, notifications) if not status then print(res) end assert(status == true) end nk.register_rpc(notification_send, "notification_send") Loading
pkg/iap/apple.go +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ func NewAppleClientWithHTTP(password string, production bool, httpClient *http.C func (ac *AppleClient) init(production bool) error { if ac.password == "" { return errors.New("Apple in-app purchase configuration is inactive. Reason: Missing password.") return errors.New("Missing password.") } return nil Loading
pkg/iap/google.go +5 −5 Original line number Diff line number Diff line Loading @@ -48,20 +48,20 @@ func NewGoogleClient(packageName string, serviceKeyFilePath string, timeout int) } if gc.packageName == "" { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Missing package name.") return nil, errors.New("Missing package name.") } if gc.serviceKeyFilePath == "" { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Missing service account key.") return nil, errors.New("Missing service account key.") } jsonContent, err := ioutil.ReadFile(gc.serviceKeyFilePath) if err != nil { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Failed to read Google service account key.") return nil, errors.New("Failed to read Google service account key.") } config, err := google.JWTConfigFromJSON(jsonContent, GOOGLE_IAP_SCOPE) if err != nil { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Failed to parse Google service account key.") return nil, errors.New("Failed to parse Google service account key.") } gc.client = config.Client(context.Background()) Loading @@ -71,7 +71,7 @@ func NewGoogleClient(packageName string, serviceKeyFilePath string, timeout int) func NewGoogleClientWithHTTP(packageName string, httpClient *http.Client) (*GoogleClient, error) { if packageName == "" { return nil, errors.New("Google in-app purchase configuration is inactive. Reason: Missing package name.") return nil, errors.New("Missing package name.") } gc := &GoogleClient{ Loading
server/core_purchase.go +2 −2 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ type PurchaseService struct { func NewPurchaseService(jsonLogger *zap.Logger, multiLogger *zap.Logger, db *sql.DB, config *PurchaseConfig) *PurchaseService { ac, err := iap.NewAppleClient(config.Apple.Password, config.Apple.Production, config.Apple.TimeoutMs) if err != nil { multiLogger.Warn("Skip initialising Apple in-app purchase provider", zap.Error(err)) multiLogger.Warn("Skip initialising Apple in-app purchase provider", zap.String("reason,", err.Error())) } else { if config.Apple.Production { multiLogger.Info("Apple in-app purchase environment is set to Production priority.") Loading @@ -48,7 +48,7 @@ func NewPurchaseService(jsonLogger *zap.Logger, multiLogger *zap.Logger, db *sql gc, err := iap.NewGoogleClient(config.Google.PackageName, config.Google.ServiceKeyFilePath, config.Google.TimeoutMs) if err != nil { multiLogger.Warn("Skip initialising Google in-app purchase provider", zap.Error(err)) multiLogger.Warn("Skip initialising Google in-app purchase provider", zap.String("reason", err.Error())) } return &PurchaseService{ Loading
tests/modules/notification.lua 0 → 100644 +32 −0 Original line number Diff line number Diff line --[[ Copyright 2017 The Nakama Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --]] local nk = require("nakama") local nx = require("nakamax") function notification_send(ctx, payload) notifications = { { Subject="test_notification",Content='{"hello": "world"}',UserId=ctx["user_id"],Code=101,Persistent=true }, } local status, res = pcall(nk.notifications_send_id, notifications) if not status then print(res) end assert(status == true) end nk.register_rpc(notification_send, "notification_send")