push_common/push_type.go

44 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}
}