remove generated files from git
This commit is contained in:
2
scnserver/.gitignore
vendored
2
scnserver/.gitignore
vendored
@@ -27,6 +27,8 @@ scn_send.sh
|
|||||||
swagger/swagger.json
|
swagger/swagger.json
|
||||||
swagger/swagger.yaml
|
swagger/swagger.yaml
|
||||||
|
|
||||||
|
**/*_gen.go
|
||||||
|
|
||||||
##############
|
##############
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,375 +0,0 @@
|
|||||||
// Code generated by enum-generate.go DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
import "git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
|
||||||
import "git.blackforestbytes.com/BlackForestBytes/goext/enums"
|
|
||||||
|
|
||||||
const ChecksumEnumGenerator = "1e8100b30bf6c946a1dfdc273b41efcaa91f33eab2bda12ce5dfa853741ac90b" // GoExtVersion: 0.0.575
|
|
||||||
|
|
||||||
// ================================ ClientType ================================
|
|
||||||
//
|
|
||||||
// File: client.go
|
|
||||||
// StringEnum: true
|
|
||||||
// DescrEnum: false
|
|
||||||
// DataEnum: false
|
|
||||||
//
|
|
||||||
|
|
||||||
var __ClientTypeValues = []ClientType{
|
|
||||||
ClientTypeAndroid,
|
|
||||||
ClientTypeIOS,
|
|
||||||
ClientTypeLinux,
|
|
||||||
ClientTypeMacOS,
|
|
||||||
ClientTypeWindows,
|
|
||||||
}
|
|
||||||
|
|
||||||
var __ClientTypeVarnames = map[ClientType]string{
|
|
||||||
ClientTypeAndroid: "ClientTypeAndroid",
|
|
||||||
ClientTypeIOS: "ClientTypeIOS",
|
|
||||||
ClientTypeLinux: "ClientTypeLinux",
|
|
||||||
ClientTypeMacOS: "ClientTypeMacOS",
|
|
||||||
ClientTypeWindows: "ClientTypeWindows",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) Valid() bool {
|
|
||||||
return langext.InArray(e, __ClientTypeValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) Values() []ClientType {
|
|
||||||
return __ClientTypeValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) ValuesAny() []any {
|
|
||||||
return langext.ArrCastToAny(__ClientTypeValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) ValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return ClientTypeValuesMeta()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) String() string {
|
|
||||||
return string(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) VarName() string {
|
|
||||||
if d, ok := __ClientTypeVarnames[e]; ok {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) TypeName() string {
|
|
||||||
return "ClientType"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) PackageName() string {
|
|
||||||
return "models"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ClientType) Meta() enums.EnumMetaValue {
|
|
||||||
return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseClientType(vv string) (ClientType, bool) {
|
|
||||||
for _, ev := range __ClientTypeValues {
|
|
||||||
if string(ev) == vv {
|
|
||||||
return ev, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func ClientTypeValues() []ClientType {
|
|
||||||
return __ClientTypeValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func ClientTypeValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return []enums.EnumMetaValue{
|
|
||||||
ClientTypeAndroid.Meta(),
|
|
||||||
ClientTypeIOS.Meta(),
|
|
||||||
ClientTypeLinux.Meta(),
|
|
||||||
ClientTypeMacOS.Meta(),
|
|
||||||
ClientTypeWindows.Meta(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ DeliveryStatus ================================
|
|
||||||
//
|
|
||||||
// File: delivery.go
|
|
||||||
// StringEnum: true
|
|
||||||
// DescrEnum: false
|
|
||||||
// DataEnum: false
|
|
||||||
//
|
|
||||||
|
|
||||||
var __DeliveryStatusValues = []DeliveryStatus{
|
|
||||||
DeliveryStatusRetry,
|
|
||||||
DeliveryStatusSuccess,
|
|
||||||
DeliveryStatusFailed,
|
|
||||||
}
|
|
||||||
|
|
||||||
var __DeliveryStatusVarnames = map[DeliveryStatus]string{
|
|
||||||
DeliveryStatusRetry: "DeliveryStatusRetry",
|
|
||||||
DeliveryStatusSuccess: "DeliveryStatusSuccess",
|
|
||||||
DeliveryStatusFailed: "DeliveryStatusFailed",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) Valid() bool {
|
|
||||||
return langext.InArray(e, __DeliveryStatusValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) Values() []DeliveryStatus {
|
|
||||||
return __DeliveryStatusValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) ValuesAny() []any {
|
|
||||||
return langext.ArrCastToAny(__DeliveryStatusValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) ValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return DeliveryStatusValuesMeta()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) String() string {
|
|
||||||
return string(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) VarName() string {
|
|
||||||
if d, ok := __DeliveryStatusVarnames[e]; ok {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) TypeName() string {
|
|
||||||
return "DeliveryStatus"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) PackageName() string {
|
|
||||||
return "models"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e DeliveryStatus) Meta() enums.EnumMetaValue {
|
|
||||||
return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseDeliveryStatus(vv string) (DeliveryStatus, bool) {
|
|
||||||
for _, ev := range __DeliveryStatusValues {
|
|
||||||
if string(ev) == vv {
|
|
||||||
return ev, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeliveryStatusValues() []DeliveryStatus {
|
|
||||||
return __DeliveryStatusValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeliveryStatusValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return []enums.EnumMetaValue{
|
|
||||||
DeliveryStatusRetry.Meta(),
|
|
||||||
DeliveryStatusSuccess.Meta(),
|
|
||||||
DeliveryStatusFailed.Meta(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ TokenPerm ================================
|
|
||||||
//
|
|
||||||
// File: keytoken.go
|
|
||||||
// StringEnum: true
|
|
||||||
// DescrEnum: true
|
|
||||||
// DataEnum: false
|
|
||||||
//
|
|
||||||
|
|
||||||
var __TokenPermValues = []TokenPerm{
|
|
||||||
PermAdmin,
|
|
||||||
PermChannelRead,
|
|
||||||
PermChannelSend,
|
|
||||||
PermUserRead,
|
|
||||||
}
|
|
||||||
|
|
||||||
var __TokenPermDescriptions = map[TokenPerm]string{
|
|
||||||
PermAdmin: "Edit userdata (+ includes all other permissions)",
|
|
||||||
PermChannelRead: "Read messages",
|
|
||||||
PermChannelSend: "Send messages",
|
|
||||||
PermUserRead: "Read userdata",
|
|
||||||
}
|
|
||||||
|
|
||||||
var __TokenPermVarnames = map[TokenPerm]string{
|
|
||||||
PermAdmin: "PermAdmin",
|
|
||||||
PermChannelRead: "PermChannelRead",
|
|
||||||
PermChannelSend: "PermChannelSend",
|
|
||||||
PermUserRead: "PermUserRead",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) Valid() bool {
|
|
||||||
return langext.InArray(e, __TokenPermValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) Values() []TokenPerm {
|
|
||||||
return __TokenPermValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) ValuesAny() []any {
|
|
||||||
return langext.ArrCastToAny(__TokenPermValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) ValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return TokenPermValuesMeta()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) String() string {
|
|
||||||
return string(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) Description() string {
|
|
||||||
if d, ok := __TokenPermDescriptions[e]; ok {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) VarName() string {
|
|
||||||
if d, ok := __TokenPermVarnames[e]; ok {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) TypeName() string {
|
|
||||||
return "TokenPerm"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) PackageName() string {
|
|
||||||
return "models"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) Meta() enums.EnumMetaValue {
|
|
||||||
return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: langext.Ptr(e.Description())}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TokenPerm) DescriptionMeta() enums.EnumDescriptionMetaValue {
|
|
||||||
return enums.EnumDescriptionMetaValue{VarName: e.VarName(), Value: e, Description: e.Description()}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTokenPerm(vv string) (TokenPerm, bool) {
|
|
||||||
for _, ev := range __TokenPermValues {
|
|
||||||
if string(ev) == vv {
|
|
||||||
return ev, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func TokenPermValues() []TokenPerm {
|
|
||||||
return __TokenPermValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func TokenPermValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return []enums.EnumMetaValue{
|
|
||||||
PermAdmin.Meta(),
|
|
||||||
PermChannelRead.Meta(),
|
|
||||||
PermChannelSend.Meta(),
|
|
||||||
PermUserRead.Meta(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TokenPermValuesDescriptionMeta() []enums.EnumDescriptionMetaValue {
|
|
||||||
return []enums.EnumDescriptionMetaValue{
|
|
||||||
PermAdmin.DescriptionMeta(),
|
|
||||||
PermChannelRead.DescriptionMeta(),
|
|
||||||
PermChannelSend.DescriptionMeta(),
|
|
||||||
PermUserRead.DescriptionMeta(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ TransactionLockMode ================================
|
|
||||||
//
|
|
||||||
// File: lock.go
|
|
||||||
// StringEnum: true
|
|
||||||
// DescrEnum: false
|
|
||||||
// DataEnum: false
|
|
||||||
//
|
|
||||||
|
|
||||||
var __TransactionLockModeValues = []TransactionLockMode{
|
|
||||||
TLockNone,
|
|
||||||
TLockRead,
|
|
||||||
TLockReadWrite,
|
|
||||||
}
|
|
||||||
|
|
||||||
var __TransactionLockModeVarnames = map[TransactionLockMode]string{
|
|
||||||
TLockNone: "TLockNone",
|
|
||||||
TLockRead: "TLockRead",
|
|
||||||
TLockReadWrite: "TLockReadWrite",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) Valid() bool {
|
|
||||||
return langext.InArray(e, __TransactionLockModeValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) Values() []TransactionLockMode {
|
|
||||||
return __TransactionLockModeValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) ValuesAny() []any {
|
|
||||||
return langext.ArrCastToAny(__TransactionLockModeValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) ValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return TransactionLockModeValuesMeta()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) String() string {
|
|
||||||
return string(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) VarName() string {
|
|
||||||
if d, ok := __TransactionLockModeVarnames[e]; ok {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) TypeName() string {
|
|
||||||
return "TransactionLockMode"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) PackageName() string {
|
|
||||||
return "models"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e TransactionLockMode) Meta() enums.EnumMetaValue {
|
|
||||||
return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTransactionLockMode(vv string) (TransactionLockMode, bool) {
|
|
||||||
for _, ev := range __TransactionLockModeValues {
|
|
||||||
if string(ev) == vv {
|
|
||||||
return ev, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func TransactionLockModeValues() []TransactionLockMode {
|
|
||||||
return __TransactionLockModeValues
|
|
||||||
}
|
|
||||||
|
|
||||||
func TransactionLockModeValuesMeta() []enums.EnumMetaValue {
|
|
||||||
return []enums.EnumMetaValue{
|
|
||||||
TLockNone.Meta(),
|
|
||||||
TLockRead.Meta(),
|
|
||||||
TLockReadWrite.Meta(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ ================= ================================
|
|
||||||
|
|
||||||
func AllPackageEnums() []enums.Enum {
|
|
||||||
return []enums.Enum{
|
|
||||||
ClientTypeAndroid, // ClientType
|
|
||||||
DeliveryStatusRetry, // DeliveryStatus
|
|
||||||
PermAdmin, // TokenPerm
|
|
||||||
TLockNone, // TransactionLockMode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,410 +0,0 @@
|
|||||||
// Code generated by csid-generate.go DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
import "crypto/rand"
|
|
||||||
import "crypto/sha256"
|
|
||||||
import "fmt"
|
|
||||||
import "github.com/go-playground/validator/v10"
|
|
||||||
import "github.com/rs/zerolog/log"
|
|
||||||
import "git.blackforestbytes.com/BlackForestBytes/goext/exerr"
|
|
||||||
import "git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
|
||||||
import "git.blackforestbytes.com/BlackForestBytes/goext/rext"
|
|
||||||
import "math/big"
|
|
||||||
import "reflect"
|
|
||||||
import "regexp"
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
const ChecksumCharsetIDGenerator = "1e8100b30bf6c946a1dfdc273b41efcaa91f33eab2bda12ce5dfa853741ac90b" // GoExtVersion: 0.0.575
|
|
||||||
|
|
||||||
const idlen = 24
|
|
||||||
|
|
||||||
const checklen = 1
|
|
||||||
|
|
||||||
const idCharset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
||||||
const idCharsetLen = len(idCharset)
|
|
||||||
|
|
||||||
var charSetReverseMap = generateCharsetMap()
|
|
||||||
|
|
||||||
const (
|
|
||||||
prefixUserID = "USR"
|
|
||||||
prefixChannelID = "CHA"
|
|
||||||
prefixDeliveryID = "DEL"
|
|
||||||
prefixMessageID = "MSG"
|
|
||||||
prefixSubscriptionID = "SUB"
|
|
||||||
prefixClientID = "CLN"
|
|
||||||
prefixRequestID = "REQ"
|
|
||||||
prefixKeyTokenID = "TOK"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
regexUserID = generateRegex(prefixUserID)
|
|
||||||
regexChannelID = generateRegex(prefixChannelID)
|
|
||||||
regexDeliveryID = generateRegex(prefixDeliveryID)
|
|
||||||
regexMessageID = generateRegex(prefixMessageID)
|
|
||||||
regexSubscriptionID = generateRegex(prefixSubscriptionID)
|
|
||||||
regexClientID = generateRegex(prefixClientID)
|
|
||||||
regexRequestID = generateRegex(prefixRequestID)
|
|
||||||
regexKeyTokenID = generateRegex(prefixKeyTokenID)
|
|
||||||
)
|
|
||||||
|
|
||||||
func generateRegex(prefix string) rext.Regex {
|
|
||||||
return rext.W(regexp.MustCompile(fmt.Sprintf("^%s[%s]{%d}[%s]{%d}$", prefix, idCharset, idlen-len(prefix)-checklen, idCharset, checklen)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateCharsetMap() []int {
|
|
||||||
result := make([]int, 128)
|
|
||||||
for i := 0; i < len(result); i++ {
|
|
||||||
result[i] = -1
|
|
||||||
}
|
|
||||||
for idx, chr := range idCharset {
|
|
||||||
result[int(chr)] = idx
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateID(prefix string) string {
|
|
||||||
k := ""
|
|
||||||
csMax := big.NewInt(int64(idCharsetLen))
|
|
||||||
checksum := 0
|
|
||||||
for i := 0; i < idlen-len(prefix)-checklen; i++ {
|
|
||||||
v, err := rand.Int(rand.Reader, csMax)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
v64 := v.Int64()
|
|
||||||
k += string(idCharset[v64])
|
|
||||||
checksum = (checksum + int(v64)) % (idCharsetLen)
|
|
||||||
}
|
|
||||||
checkstr := string(idCharset[checksum%idCharsetLen])
|
|
||||||
return prefix + k + checkstr
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateIDFromSeed(prefix string, seed string) string {
|
|
||||||
h := sha256.New()
|
|
||||||
|
|
||||||
iddata := ""
|
|
||||||
for len(iddata) < idlen-len(prefix)-checklen {
|
|
||||||
h.Write([]byte(seed))
|
|
||||||
bs := h.Sum(nil)
|
|
||||||
iddata += langext.NewAnyBaseConverter(idCharset).Encode(bs)
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum := 0
|
|
||||||
for i := 0; i < idlen-len(prefix)-checklen; i++ {
|
|
||||||
ichr := int(iddata[i])
|
|
||||||
checksum = (checksum + charSetReverseMap[ichr]) % (idCharsetLen)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkstr := string(idCharset[checksum%idCharsetLen])
|
|
||||||
|
|
||||||
return prefix + iddata[:(idlen-len(prefix)-checklen)] + checkstr
|
|
||||||
}
|
|
||||||
|
|
||||||
func validateID(prefix string, value string) error {
|
|
||||||
if len(value) != idlen {
|
|
||||||
return exerr.New(exerr.TypeInvalidCSID, "id has the wrong length").Str("value", value).Build()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.HasPrefix(value, prefix) {
|
|
||||||
return exerr.New(exerr.TypeInvalidCSID, "id is missing the correct prefix").Str("value", value).Str("prefix", prefix).Build()
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum := 0
|
|
||||||
for i := len(prefix); i < len(value)-checklen; i++ {
|
|
||||||
ichr := int(value[i])
|
|
||||||
if ichr < 0 || ichr >= len(charSetReverseMap) || charSetReverseMap[ichr] == -1 {
|
|
||||||
return exerr.New(exerr.TypeInvalidCSID, "id contains invalid characters").Str("value", value).Build()
|
|
||||||
}
|
|
||||||
checksum = (checksum + charSetReverseMap[ichr]) % (idCharsetLen)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkstr := string(idCharset[checksum%idCharsetLen])
|
|
||||||
|
|
||||||
if !strings.HasSuffix(value, checkstr) {
|
|
||||||
return exerr.New(exerr.TypeInvalidCSID, "id checkstring is invalid").Str("value", value).Str("checkstr", checkstr).Build()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getRawData(prefix string, value string) string {
|
|
||||||
if len(value) != idlen {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return value[len(prefix) : idlen-checklen]
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCheckString(prefix string, value string) string {
|
|
||||||
if len(value) != idlen {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return value[idlen-checklen:]
|
|
||||||
}
|
|
||||||
|
|
||||||
func ValidateEntityID(vfl validator.FieldLevel) bool {
|
|
||||||
if !vfl.Field().CanInterface() {
|
|
||||||
log.Error().Msgf("Failed to validate EntityID (cannot interface ?!?)")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
ifvalue := vfl.Field().Interface()
|
|
||||||
|
|
||||||
if value1, ok := ifvalue.(EntityID); ok {
|
|
||||||
|
|
||||||
if vfl.Field().Type().Kind() == reflect.Pointer && langext.IsNil(value1) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := value1.Valid(); err != nil {
|
|
||||||
log.Debug().Msgf("Failed to validate EntityID '%s' (%s)", value1.String(), err.Error())
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log.Error().Msgf("Failed to validate EntityID (wrong type: %T)", ifvalue)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ UserID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewUserID() UserID {
|
|
||||||
return UserID(generateID(prefixUserID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id UserID) Valid() error {
|
|
||||||
return validateID(prefixUserID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i UserID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i UserID) Prefix() string {
|
|
||||||
return prefixUserID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id UserID) Raw() string {
|
|
||||||
return getRawData(prefixUserID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id UserID) CheckString() string {
|
|
||||||
return getCheckString(prefixUserID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id UserID) Regex() rext.Regex {
|
|
||||||
return regexUserID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ ChannelID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewChannelID() ChannelID {
|
|
||||||
return ChannelID(generateID(prefixChannelID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ChannelID) Valid() error {
|
|
||||||
return validateID(prefixChannelID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i ChannelID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i ChannelID) Prefix() string {
|
|
||||||
return prefixChannelID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ChannelID) Raw() string {
|
|
||||||
return getRawData(prefixChannelID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ChannelID) CheckString() string {
|
|
||||||
return getCheckString(prefixChannelID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ChannelID) Regex() rext.Regex {
|
|
||||||
return regexChannelID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ DeliveryID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewDeliveryID() DeliveryID {
|
|
||||||
return DeliveryID(generateID(prefixDeliveryID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id DeliveryID) Valid() error {
|
|
||||||
return validateID(prefixDeliveryID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i DeliveryID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i DeliveryID) Prefix() string {
|
|
||||||
return prefixDeliveryID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id DeliveryID) Raw() string {
|
|
||||||
return getRawData(prefixDeliveryID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id DeliveryID) CheckString() string {
|
|
||||||
return getCheckString(prefixDeliveryID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id DeliveryID) Regex() rext.Regex {
|
|
||||||
return regexDeliveryID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ MessageID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewMessageID() MessageID {
|
|
||||||
return MessageID(generateID(prefixMessageID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id MessageID) Valid() error {
|
|
||||||
return validateID(prefixMessageID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i MessageID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i MessageID) Prefix() string {
|
|
||||||
return prefixMessageID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id MessageID) Raw() string {
|
|
||||||
return getRawData(prefixMessageID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id MessageID) CheckString() string {
|
|
||||||
return getCheckString(prefixMessageID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id MessageID) Regex() rext.Regex {
|
|
||||||
return regexMessageID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ SubscriptionID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewSubscriptionID() SubscriptionID {
|
|
||||||
return SubscriptionID(generateID(prefixSubscriptionID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id SubscriptionID) Valid() error {
|
|
||||||
return validateID(prefixSubscriptionID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i SubscriptionID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i SubscriptionID) Prefix() string {
|
|
||||||
return prefixSubscriptionID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id SubscriptionID) Raw() string {
|
|
||||||
return getRawData(prefixSubscriptionID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id SubscriptionID) CheckString() string {
|
|
||||||
return getCheckString(prefixSubscriptionID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id SubscriptionID) Regex() rext.Regex {
|
|
||||||
return regexSubscriptionID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ ClientID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewClientID() ClientID {
|
|
||||||
return ClientID(generateID(prefixClientID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ClientID) Valid() error {
|
|
||||||
return validateID(prefixClientID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i ClientID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i ClientID) Prefix() string {
|
|
||||||
return prefixClientID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ClientID) Raw() string {
|
|
||||||
return getRawData(prefixClientID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ClientID) CheckString() string {
|
|
||||||
return getCheckString(prefixClientID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id ClientID) Regex() rext.Regex {
|
|
||||||
return regexClientID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ RequestID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewRequestID() RequestID {
|
|
||||||
return RequestID(generateID(prefixRequestID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id RequestID) Valid() error {
|
|
||||||
return validateID(prefixRequestID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i RequestID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i RequestID) Prefix() string {
|
|
||||||
return prefixRequestID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id RequestID) Raw() string {
|
|
||||||
return getRawData(prefixRequestID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id RequestID) CheckString() string {
|
|
||||||
return getCheckString(prefixRequestID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id RequestID) Regex() rext.Regex {
|
|
||||||
return regexRequestID
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================ KeyTokenID (ids.go) ================================
|
|
||||||
|
|
||||||
func NewKeyTokenID() KeyTokenID {
|
|
||||||
return KeyTokenID(generateID(prefixKeyTokenID))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id KeyTokenID) Valid() error {
|
|
||||||
return validateID(prefixKeyTokenID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i KeyTokenID) String() string {
|
|
||||||
return string(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i KeyTokenID) Prefix() string {
|
|
||||||
return prefixKeyTokenID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id KeyTokenID) Raw() string {
|
|
||||||
return getRawData(prefixKeyTokenID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id KeyTokenID) CheckString() string {
|
|
||||||
return getCheckString(prefixKeyTokenID, string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (id KeyTokenID) Regex() rext.Regex {
|
|
||||||
return regexKeyTokenID
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user