PLT-902 switching to push proxy server
Этот коммит содержится в:
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
l4g "code.google.com/p/log4go"
|
||||
"fmt"
|
||||
"github.com/anachronistic/apns"
|
||||
"github.com/mattermost/platform/model"
|
||||
)
|
||||
|
||||
func SendAppleNotifyAndForget(deviceId string, message string, badge int) {
|
||||
go func() {
|
||||
if err := SendAppleNotify(deviceId, message, badge); err != nil {
|
||||
l4g.Error(fmt.Sprintf("%v %v", err.Message, err.DetailedError))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func SendAppleNotify(deviceId string, message string, badge int) *model.AppError {
|
||||
payload := apns.NewPayload()
|
||||
payload.Alert = message
|
||||
payload.Badge = 1
|
||||
|
||||
pn := apns.NewPushNotification()
|
||||
pn.DeviceToken = deviceId
|
||||
pn.AddPayload(payload)
|
||||
client := apns.BareClient(Cfg.EmailSettings.ApplePushServer, Cfg.EmailSettings.ApplePushCertPublic, Cfg.EmailSettings.ApplePushCertPrivate)
|
||||
resp := client.Send(pn)
|
||||
|
||||
if resp.Error != nil {
|
||||
return model.NewAppError("", "Could not send apple push notification", fmt.Sprintf("id=%v err=%v", deviceId, resp.Error))
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ const (
|
||||
)
|
||||
|
||||
var Cfg *model.Config = &model.Config{}
|
||||
var CfgDiagnosticId = ""
|
||||
var CfgLastModified int64 = 0
|
||||
var CfgFileName string = ""
|
||||
var ClientCfg map[string]string = map[string]string{}
|
||||
|
||||
Ссылка в новой задаче
Block a user