Files
mtusi2026lab3/internal/app/chat/current_user.go
T
2026-10-20 20:46:51 +03:00

22 lines
562 B
Go

package chat
import (
"net/http"
"github.com/labstack/echo/v4"
"gitflic.ru/akselbant/mtusi2026lab1-fork/dto"
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/domain"
)
func (h *Chat) currentUser(c echo.Context) error {
user := authenticatedUser(c)
return c.JSON(http.StatusOK, currentUserResponseFromDomain(user))
}
func currentUserResponseFromDomain(user domain.User) dto.CurrentUserResponse {
return dto.CurrentUserResponse{
ID: user.ID, Username: user.Username, DisplayName: user.DisplayName, CreatedAt: dto.Timestamp(user.CreatedAt),
}
}