Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
528 B
Go
32 lines
528 B
Go
package entity
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/teris-io/shortid"
|
|
)
|
|
|
|
const (
|
|
qrTokenMin = 9
|
|
qrTokenMax = 20
|
|
)
|
|
|
|
// NewQRCode is an opaque scan ticket from shortid. It is not uid, spark_id, or a Redis key.
|
|
func NewQRCode() (string, error) {
|
|
return shortid.Generate()
|
|
}
|
|
|
|
func ValidQRCode(s string) bool {
|
|
s = strings.TrimSpace(s)
|
|
n := len(s)
|
|
if n < qrTokenMin || n > qrTokenMax {
|
|
return false
|
|
}
|
|
for i := 0; i < n; i++ {
|
|
if !strings.ContainsRune(shortid.DefaultABC, rune(s[i])) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|