From 164beb90d486a0214de5762ce9a4ad6502ab3456 Mon Sep 17 00:00:00 2001 From: Vladislav Veselskiy Date: Thu, 6 Feb 2025 13:46:39 +0300 Subject: [PATCH] Add type Push. --- push_common.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/push_common.go b/push_common.go index b8bac2c..a84451e 100644 --- a/push_common.go +++ b/push_common.go @@ -239,3 +239,53 @@ func ReadPayloadFromRequest(request *http.Request, payload *PushPayload) error { return json.Unmarshal(b, payload) } + +//----------------------------------------------------------------------------- + +type Push struct { + Id uint32 `json:"id"` + Status int `json:"status"` + Ctime uint32 `json:"ctime"` + Mtime uint32 `json:"mtime"` + Ttl uint32 `json:"ttl"` + Stime uint32 `json:"stime"` + Srtime uint32 `json:"srtime"` + Info string `json:"info"` + Label string `json:"label"` + MaxVersion string `json:"maxVersion,omitempty"` + Platforms []uint32 `json:"platforms,omitempty"` + PlayersIds []uint32 `json:"playersIds,omitempty"` + Title string `json:"title"` + Message string `json:"message"` + TextVariants []*TextVariant `json:"textVariants"` // For incoming push only. + Jobs []*PushJob `json:"jobs"` // Incoming push has no jobs. + Total int `json:"total"` + Sent int `json:"sent"` // Incoming push has not field "Sent". + Fails int `json:"fails"` // Incoming push has not field "Fails". + ForTest bool `json:"forTest,omitempty"` + ImageUrl string `json:"imageUrl,omitempty"` +} + +func (push *Push) IsDone() bool { + return push.Total == (push.Sent + push.Fails) +} + +//----------------------------------------------------------------------------- + +type JobId uint32 + +type PushJob struct { + Id JobId `json:"id"` + Platform Platform `json:"platform"` + Message string `json:"message"` + Title string `json:"title"` + Language int `json:"language"` + Utc_delta int `json:"utc_delta"` + Total int `json:"total"` + Sent int `json:"sent"` + Fails int `json:"fails"` +} + +func (job *PushJob) IsDone() bool { + return job.Total == (job.Sent + job.Fails) +}