mirror of
https://github.com/tgdrive/teldrive.git
synced 2024-11-14 19:56:33 +08:00
85 lines
1.6 KiB
Go
85 lines
1.6 KiB
Go
|
package controller
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/divyam234/teldrive/pkg/httputil"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func (uc *Controller) Stats(c *gin.Context) {
|
||
|
res, err := uc.UserService.Stats(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) GetBots(c *gin.Context) {
|
||
|
res, err := uc.UserService.GetBots(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) UpdateChannel(c *gin.Context) {
|
||
|
res, err := uc.UserService.UpdateChannel(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) ListChannels(c *gin.Context) {
|
||
|
res, err := uc.UserService.ListChannels(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) AddBots(c *gin.Context) {
|
||
|
res, err := uc.UserService.AddBots(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) RemoveBots(c *gin.Context) {
|
||
|
res, err := uc.UserService.RemoveBots(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) RevokeBotSession(c *gin.Context) {
|
||
|
res, err := uc.UserService.RevokeBotSession(c)
|
||
|
if err != nil {
|
||
|
httputil.NewError(c, err.Code, err.Error)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.JSON(http.StatusOK, res)
|
||
|
}
|
||
|
|
||
|
func (uc *Controller) GetProfilePhoto(c *gin.Context) {
|
||
|
if c.Query("photo") != "" {
|
||
|
uc.UserService.GetProfilePhoto(c)
|
||
|
}
|
||
|
}
|