103 lines
2.7 KiB
Go
103 lines
2.7 KiB
Go
// Copyright (c) 2025 Nikolai Papin
|
|
//
|
|
// This file is part of Easywish
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
// the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"easywish/internal/middleware"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ProfileController interface {
|
|
GetProfile(c *gin.Context)
|
|
GetOwnProfile(c *gin.Context)
|
|
UpdateProfile(c *gin.Context)
|
|
GetPrivacySettings(c *gin.Context)
|
|
UpdatePrivacySettings(c *gin.Context)
|
|
Router
|
|
}
|
|
|
|
type profileControllerImpl struct {
|
|
}
|
|
|
|
func NewProfileController() ProfileController {
|
|
return &profileControllerImpl{}
|
|
}
|
|
|
|
// @Summary Get someone's profile details
|
|
// @Tags Profile
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param username path string true "Username"
|
|
// @Security JWT
|
|
// @Router /profile/{username} [get]
|
|
func (p *profileControllerImpl) GetProfile(c *gin.Context) {
|
|
c.Status(http.StatusNotImplemented)
|
|
}
|
|
|
|
// @Summary Get own profile when authorized
|
|
// @Tags Profile
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security JWT
|
|
// @Router /profile/me [get]
|
|
func (p *profileControllerImpl) GetOwnProfile(c *gin.Context) {
|
|
c.Status(http.StatusNotImplemented)
|
|
}
|
|
|
|
// @Summary Update profile
|
|
// @Tags Profile
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security JWT
|
|
// @Router /profile [patch]
|
|
func (p *profileControllerImpl) UpdateProfile(c *gin.Context) {
|
|
c.Status(http.StatusNotImplemented)
|
|
}
|
|
|
|
// @Summary Get profile privacy settings
|
|
// @Tags Profile
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security JWT
|
|
// @Router /profile/privacy [get]
|
|
func (p *profileControllerImpl) GetPrivacySettings(c *gin.Context) {
|
|
c.Status(http.StatusNotImplemented)
|
|
}
|
|
|
|
// @Summary Update profile privacy settings
|
|
// @Tags Profile
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security JWT
|
|
// @Router /profile/privacy [patch]
|
|
func (p *profileControllerImpl) UpdatePrivacySettings(c *gin.Context) {
|
|
c.Status(http.StatusNotImplemented)
|
|
}
|
|
|
|
func (p *profileControllerImpl) RegisterRoutes(group *gin.RouterGroup) {
|
|
protected := group.Group("")
|
|
protected.Use(middleware.JWTAuthMiddleware())
|
|
{
|
|
protected.GET("/me", p.GetOwnProfile)
|
|
protected.GET("/:username", p.GetProfile)
|
|
protected.GET("/privacy", p.GetPrivacySettings)
|
|
}
|
|
}
|