Refactoring for Gin, NoSurf and SCS continues.
This commit is contained in:
@@ -6,9 +6,12 @@ import (
|
||||
"net/http"
|
||||
|
||||
httpHelper "synlotto-website/internal/helpers/http"
|
||||
// ToDo: again, need to check if i should be using multiple stotage entries like this or if this si even correct would it not be a helper?
|
||||
messageStorage "synlotto-website/internal/storage/messages"
|
||||
notificationStorage "synlotto-website/internal/storage/notifications"
|
||||
usersStorage "synlotto-website/internal/storage/users"
|
||||
|
||||
"synlotto-website/internal/models"
|
||||
"synlotto-website/internal/storage"
|
||||
)
|
||||
|
||||
func BuildTemplateData(db *sql.DB, w http.ResponseWriter, r *http.Request) models.TemplateData {
|
||||
@@ -25,13 +28,13 @@ func BuildTemplateData(db *sql.DB, w http.ResponseWriter, r *http.Request) model
|
||||
var messages []models.Message
|
||||
|
||||
if userId, ok := session.Values["user_id"].(int); ok {
|
||||
user = storage.GetUserByID(db, userId)
|
||||
user = usersStorage.GetUserByID(db, userId)
|
||||
if user != nil {
|
||||
isAdmin = user.IsAdmin
|
||||
notificationCount = storage.GetNotificationCount(db, user.Id)
|
||||
notifications = storage.GetRecentNotifications(db, user.Id, 15)
|
||||
messageCount, _ = storage.GetMessageCount(db, user.Id)
|
||||
messages = storage.GetRecentMessages(db, user.Id, 15)
|
||||
notificationCount = notificationStorage.GetNotificationCount(db, user.Id)
|
||||
notifications = notificationStorage.GetRecentNotifications(db, user.Id, 15)
|
||||
messageCount, _ = messageStorage.GetMessageCount(db, user.Id)
|
||||
messages = messageStorage.GetRecentMessages(db, user.Id, 15)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user