Add file push_type.go.

This commit is contained in:
Владислав Весельский 2025-02-06 18:12:54 +03:00
parent 164beb90d4
commit 3ab1191cd2
1 changed files with 43 additions and 0 deletions

43
push_type.go Normal file
View File

@ -0,0 +1,43 @@
package push_common
import "strings"
type PushType uint8
const (
PushType_User PushType = 1
PushType_Auto PushType = 2
)
func PushTypeToString(pt PushType) string {
switch pt {
case PushType_User:
return "user"
case PushType_Auto:
return "auto"
}
return "error"
}
const AutoPushInfoPrefix = "#"
// Автоматическое пуш-оповещение - пуш-оповещение,
// которое было создано автоматически (а не пользователем инсайдера).
func IsAutoPush(pushInfo string) bool {
return strings.HasPrefix(pushInfo, AutoPushInfoPrefix)
}
// Пользовательское пуш-оповещение - пуш-оповещение,
// которое было создано пользователем инсайдера (а не автоматически).
func IsUserPush(pushInfo string) bool {
isAuto := IsAutoPush(pushInfo)
return !isAuto
}
func ConvertPushInfoToType(pushInfo string) PushType {
if IsAutoPush(pushInfo) {
return PushType_Auto
} else {
return PushType_User
}
}