Files
SingBox-Gopanel/internal/handler/subscribe_handler.go
CN-JS-HuiBai 981ee4f406
All checks were successful
build / build (api, amd64, linux) (push) Successful in -47s
build / build (api, arm64, linux) (push) Successful in -47s
build / build (api.exe, amd64, windows) (push) Successful in -48s
基本功能复刻完成
2026-04-17 12:24:00 +08:00

31 lines
555 B
Go

package handler
import (
"net/http"
"xboard-go/internal/database"
"xboard-go/internal/model"
"github.com/gin-gonic/gin"
)
func Subscribe(c *gin.Context) {
token := c.Param("token")
if token == "" {
Fail(c, http.StatusForbidden, "token is required")
return
}
var user model.User
if err := database.DB.Where("token = ?", token).First(&user).Error; err != nil {
Fail(c, http.StatusForbidden, "invalid token")
return
}
if user.Banned {
Fail(c, http.StatusForbidden, "account is banned")
return
}
FulfillSubscription(c, &user)
}