2022-11-13 19:17:07 +01:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"blackforestbytes.com/simplecloudnotifier/api/models"
|
|
|
|
"blackforestbytes.com/simplecloudnotifier/common/ginresp"
|
|
|
|
"blackforestbytes.com/simplecloudnotifier/logic"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CompatHandler struct {
|
|
|
|
app *logic.Application
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCompatHandler(app *logic.Application) CompatHandler {
|
|
|
|
return CompatHandler{
|
|
|
|
app: app,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Register a new account
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-register
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Param fcm_token query string true "the (android) fcm token"
|
|
|
|
// @Param pro query string true "if the user is a paid account" Enums(true, false)
|
|
|
|
// @Param pro_token query string true "the (android) IAP token"
|
|
|
|
// @Success 200 {object} handler.Register.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/register.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Register(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
2022-11-13 22:31:28 +01:00
|
|
|
FCMToken *string `form:"fcm_token"`
|
|
|
|
Pro *string `form:"pro"`
|
|
|
|
ProToken *string `form:"pro_token"`
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
type response struct {
|
2022-11-13 22:31:28 +01:00
|
|
|
Success bool `json:"success"`
|
2022-11-13 19:17:07 +01:00
|
|
|
Message string `json:"message"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
UserKey string `json:"user_key"`
|
2022-11-13 22:31:28 +01:00
|
|
|
QuotaUsed int `json:"quota"`
|
|
|
|
QuotaMax int `json:"quota_max"`
|
|
|
|
IsPro int `json:"is_pro"`
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
//TODO
|
2022-11-13 22:31:28 +01:00
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Info swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Get information about the current user
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-info
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Param user_id query string true "the user_id"
|
|
|
|
// @Param user_key query string true "the user_key"
|
|
|
|
// @Success 200 {object} handler.Info.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/info.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Info(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
|
|
|
UserID string `form:"user_id"`
|
|
|
|
UserKey string `form:"user_key"`
|
|
|
|
}
|
|
|
|
type response struct {
|
|
|
|
Success string `json:"success"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
UserKey string `json:"user_key"`
|
|
|
|
QuotaUsed string `json:"quota"`
|
|
|
|
QuotaMax string `json:"quota_max"`
|
|
|
|
IsPro string `json:"is_pro"`
|
|
|
|
FCMSet bool `json:"fcm_token_set"`
|
|
|
|
UnackCount int `json:"unack_count"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ack swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Acknowledge that a message was received
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-ack
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Param user_id query string true "the user_id"
|
|
|
|
// @Param user_key query string true "the user_key"
|
|
|
|
// @Param scn_msg_id query string true "the message id"
|
|
|
|
// @Success 200 {object} handler.Ack.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/ack.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Ack(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
|
|
|
UserID string `form:"user_id"`
|
|
|
|
UserKey string `form:"user_key"`
|
|
|
|
MessageID string `form:"scn_msg_id"`
|
|
|
|
}
|
|
|
|
type response struct {
|
|
|
|
Success string `json:"success"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
PrevAckValue int `json:"prev_ack"`
|
|
|
|
NewAckValue int `json:"new_ack"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Requery swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Return all not-acknowledged messages
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-requery
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Param user_id query string true "the user_id"
|
|
|
|
// @Param user_key query string true "the user_key"
|
|
|
|
// @Success 200 {object} handler.Requery.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/requery.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Requery(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
|
|
|
UserID string `form:"user_id"`
|
|
|
|
UserKey string `form:"user_key"`
|
|
|
|
}
|
|
|
|
type response struct {
|
|
|
|
Success string `json:"success"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Count int `json:"count"`
|
|
|
|
Data []models.CompatMessage `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Set the fcm-token (android)
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-update
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Param user_id query string true "the user_id"
|
|
|
|
// @Param user_key query string true "the user_key"
|
|
|
|
// @Param fcm_token query string true "the (android) fcm token"
|
|
|
|
// @Success 200 {object} handler.Update.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/update.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Update(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
|
|
|
UserID string `form:"user_id"`
|
|
|
|
UserKey string `form:"user_key"`
|
|
|
|
FCMToken string `form:"fcm_token"`
|
|
|
|
}
|
|
|
|
type response struct {
|
|
|
|
Success string `json:"success"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
UserKey string `json:"user_key"`
|
|
|
|
QuotaUsed string `json:"quota"`
|
|
|
|
QuotaMax string `json:"quota_max"`
|
|
|
|
IsPro string `json:"is_pro"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Expand swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Get a whole (potentially truncated) message
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-expand
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Success 200 {object} handler.Expand.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/expand.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Expand(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
|
|
|
UserID string `form:"user_id"`
|
|
|
|
UserKey string `form:"user_key"`
|
|
|
|
MessageID string `form:"scn_msg_id"`
|
|
|
|
}
|
|
|
|
type response struct {
|
|
|
|
Success string `json:"success"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Data models.ShortCompatMessage `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Upgrade swaggerdoc
|
|
|
|
//
|
|
|
|
// @Summary Upgrade a free account to a paid account
|
2022-11-13 22:31:28 +01:00
|
|
|
// @ID compat-upgrade
|
2022-11-13 19:17:07 +01:00
|
|
|
// @Param user_id query string true "the user_id"
|
|
|
|
// @Param user_key query string true "the user_key"
|
|
|
|
// @Param pro query string true "if the user is a paid account" Enums(true, false)
|
|
|
|
// @Param pro_token query string true "the (android) IAP token"
|
|
|
|
// @Success 200 {object} handler.Upgrade.response
|
2022-11-18 21:25:40 +01:00
|
|
|
// @Failure 500 {object} ginresp.apiError
|
|
|
|
// @Router /api/upgrade.php [get]
|
2022-11-13 19:17:07 +01:00
|
|
|
func (h CompatHandler) Upgrade(g *gin.Context) ginresp.HTTPResponse {
|
|
|
|
type query struct {
|
|
|
|
UserID string `form:"user_id"`
|
|
|
|
UserKey string `form:"user_key"`
|
|
|
|
Pro string `form:"pro"`
|
|
|
|
ProToken string `form:"pro_token"`
|
|
|
|
}
|
|
|
|
type response struct {
|
|
|
|
Success string `json:"success"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Data models.ShortCompatMessage `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
2022-11-18 21:25:40 +01:00
|
|
|
return ginresp.NotImplemented()
|
2022-11-13 19:17:07 +01:00
|
|
|
}
|