Add Huawei Mobile Services Support to Gorush (#523)

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
M. Salih Karakaşlı
2020-09-04 06:01:21 +03:00
committed by GitHub
parent 3db8b4f006
commit 3918fab908
23 changed files with 829 additions and 14 deletions

View File

@@ -47,6 +47,8 @@ func (s *Storage) Reset() {
s.setBuntDB(storage.IosErrorKey, 0)
s.setBuntDB(storage.AndroidSuccessKey, 0)
s.setBuntDB(storage.AndroidErrorKey, 0)
s.setBuntDB(storage.HuaweiSuccessKey, 0)
s.setBuntDB(storage.HuaweiErrorKey, 0)
}
func (s *Storage) setBuntDB(key string, count int64) {
@@ -104,6 +106,18 @@ func (s *Storage) AddAndroidError(count int64) {
s.setBuntDB(storage.AndroidErrorKey, total)
}
// AddHuaweiSuccess record counts of success Huawei push notification.
func (s *Storage) AddHuaweiSuccess(count int64) {
total := s.GetHuaweiSuccess() + count
s.setBuntDB(storage.HuaweiSuccessKey, total)
}
// AddHuaweiError record counts of error Huawei push notification.
func (s *Storage) AddHuaweiError(count int64) {
total := s.GetHuaweiError() + count
s.setBuntDB(storage.HuaweiErrorKey, total)
}
// GetTotalCount show counts of all notification.
func (s *Storage) GetTotalCount() int64 {
var count int64
@@ -143,3 +157,19 @@ func (s *Storage) GetAndroidError() int64 {
return count
}
// GetHuaweiSuccess show success counts of Huawei notification.
func (s *Storage) GetHuaweiSuccess() int64 {
var count int64
s.getBuntDB(storage.HuaweiSuccessKey, &count)
return count
}
// GetHuaweiError show error counts of Huawei notification.
func (s *Storage) GetHuaweiError() int64 {
var count int64
s.getBuntDB(storage.HuaweiErrorKey, &count)
return count
}