Add Huawei Mobile Services Support to Gorush (#523)
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
committed by
GitHub
parent
3db8b4f006
commit
3918fab908
@@ -9,6 +9,7 @@ type statApp struct {
|
||||
TotalCount int64 `json:"total_count"`
|
||||
Ios IosStatus `json:"ios"`
|
||||
Android AndroidStatus `json:"android"`
|
||||
Huawei HuaweiStatus `json:"huawei"`
|
||||
}
|
||||
|
||||
// AndroidStatus is android structure
|
||||
@@ -23,6 +24,12 @@ type IosStatus struct {
|
||||
PushError int64 `json:"push_error"`
|
||||
}
|
||||
|
||||
// HuaweiStatus is android structure
|
||||
type HuaweiStatus struct {
|
||||
PushSuccess int64 `json:"push_success"`
|
||||
PushError int64 `json:"push_error"`
|
||||
}
|
||||
|
||||
// New func implements the storage interface for gorush (https://github.com/appleboy/gorush)
|
||||
func New() *Storage {
|
||||
return &Storage{
|
||||
@@ -52,6 +59,8 @@ func (s *Storage) Reset() {
|
||||
atomic.StoreInt64(&s.stat.Ios.PushError, 0)
|
||||
atomic.StoreInt64(&s.stat.Android.PushSuccess, 0)
|
||||
atomic.StoreInt64(&s.stat.Android.PushError, 0)
|
||||
atomic.StoreInt64(&s.stat.Huawei.PushSuccess, 0)
|
||||
atomic.StoreInt64(&s.stat.Huawei.PushError, 0)
|
||||
}
|
||||
|
||||
// AddTotalCount record push notification count.
|
||||
@@ -79,6 +88,16 @@ func (s *Storage) AddAndroidError(count int64) {
|
||||
atomic.AddInt64(&s.stat.Android.PushError, count)
|
||||
}
|
||||
|
||||
// AddHuaweiSuccess record counts of success Huawei push notification.
|
||||
func (s *Storage) AddHuaweiSuccess(count int64) {
|
||||
atomic.AddInt64(&s.stat.Huawei.PushSuccess, count)
|
||||
}
|
||||
|
||||
// AddHuaweiError record counts of error Huawei push notification.
|
||||
func (s *Storage) AddHuaweiError(count int64) {
|
||||
atomic.AddInt64(&s.stat.Huawei.PushError, count)
|
||||
}
|
||||
|
||||
// GetTotalCount show counts of all notification.
|
||||
func (s *Storage) GetTotalCount() int64 {
|
||||
count := atomic.LoadInt64(&s.stat.TotalCount)
|
||||
@@ -113,3 +132,17 @@ func (s *Storage) GetAndroidError() int64 {
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
// GetHuaweiSuccess show success counts of Huawei notification.
|
||||
func (s *Storage) GetHuaweiSuccess() int64 {
|
||||
count := atomic.LoadInt64(&s.stat.Huawei.PushSuccess)
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
// GetHuaweiError show error counts of Huawei notification.
|
||||
func (s *Storage) GetHuaweiError() int64 {
|
||||
count := atomic.LoadInt64(&s.stat.Huawei.PushError)
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user