@ -31,6 +31,13 @@ func DELETE(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = app.Server.Service.RemoveUserFilesCache(r.Context(), userSession.UserID)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = app.Server.Storage.Delete(r.Context(), fmt.Sprintf("%s/%s", file.OwnerID.String(), file.ID.String()))
|
err = app.Server.Storage.Delete(r.Context(), fmt.Sprintf("%s/%s", file.OwnerID.String(), file.ID.String()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func GET(w http.ResponseWriter, r *http.Request) {
|
func GET(w http.ResponseWriter, r *http.Request) {
|
||||||
userSession := r.Context().Value("user").(types.User)
|
userSession := r.Context().Value("user").(types.User)
|
||||||
files, err := app.Server.Database.GetFiles(userSession.UserID.String(), "", types.All)
|
files, err := app.Server.Service.GetUserFiles(r.Context(), userSession.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
@ -21,7 +21,7 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
|||||||
var filesData []types.FileData
|
var filesData []types.FileData
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
userFile, err := app.Server.Service.GetUserFile(r.Context(), file.ID)
|
userFile, err := app.Server.Service.GetFileDetail(r.Context(), file.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
@ -37,7 +37,8 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
|||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
usage, err := app.Server.Service.GetUserStorageUsage(r.Context(), userSession.UserID.String())
|
|
||||||
|
usage, err := app.Server.Service.CalculateUserStorageUsage(r.Context(), userSession.UserID.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
@ -63,4 +64,5 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
|||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
|||||||
var filesData []types.FileData
|
var filesData []types.FileData
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
userFile, err := app.Server.Service.GetUserFile(r.Context(), file.ID)
|
userFile, err := app.Server.Service.GetFileDetail(r.Context(), file.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
|
@ -36,14 +36,21 @@ func PATCH(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Server.Service.DeleteFileCache(r.Context(), fileID)
|
err = app.Server.Service.RemoveFileCache(r.Context(), fileID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userFile, err := app.Server.Service.GetUserFile(r.Context(), newFile.ID)
|
err = app.Server.Service.RemoveUserFilesCache(r.Context(), userSession.UserID)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userFile, err := app.Server.Service.GetFileDetail(r.Context(), newFile.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
|
@ -52,7 +52,14 @@ func POST(w http.ResponseWriter, r *http.Request) {
|
|||||||
app.Server.Logger.Error("error copying byte to file dst: " + err.Error())
|
app.Server.Logger.Error("error copying byte to file dst: " + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Server.Service.UpdateFileChunk(r.Context(), file.ID, file.OwnerID, rawIndex, file.TotalChunk)
|
err = app.Server.Service.UpdateFileChunk(r.Context(), file.ID, file.OwnerID, rawIndex, file.TotalChunk)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusAccepted)
|
w.WriteHeader(http.StatusAccepted)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -29,19 +29,27 @@ func PUT(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Server.Service.DeleteFileCache(r.Context(), fileID)
|
err = app.Server.Service.RemoveFileCache(r.Context(), fileID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userFile, err := app.Server.Service.GetUserFile(r.Context(), file.ID)
|
err = app.Server.Service.RemoveUserFilesCache(r.Context(), userSession.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userFile, err := app.Server.Service.GetFileDetail(r.Context(), file.ID)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
component := fileView.JustFile(*userFile)
|
component := fileView.JustFile(*userFile)
|
||||||
err = component.Render(r.Context(), w)
|
err = component.Render(r.Context(), w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -122,7 +122,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Server.Service.DeleteUser(r.Context(), userData.User.Email)
|
err = app.Server.Service.RemoveUserCache(r.Context(), userData.User.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
|
@ -51,7 +51,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Server.Service.DeleteUser(r.Context(), userSession.Email)
|
err = app.Server.Service.RemoveUserCache(r.Context(), userSession.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
|
@ -87,7 +87,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
|
|||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := app.Server.Service.DeleteUser(r.Context(), userSession.Email)
|
err := app.Server.Service.RemoveUserCache(r.Context(), userSession.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
|
133
handler/user/totp/setup.go~
Normal file
133
handler/user/totp/setup.go~
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
package userHandlerTotpSetup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
"github.com/a-h/templ"
|
||||||
|
"github.com/fossyy/filekeeper/app"
|
||||||
|
"github.com/fossyy/filekeeper/view/client/user/totp"
|
||||||
|
"image/png"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/fossyy/filekeeper/types"
|
||||||
|
"github.com/skip2/go-qrcode"
|
||||||
|
"github.com/xlzd/gotp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func generateQRCode(uri string) (string, error) {
|
||||||
|
qr, err := qrcode.New(uri, qrcode.Medium)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to generate QR code: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
if err := png.Encode(&buffer, qr.Image(256)); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to encode QR code to PNG: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return base64.StdEncoding.EncodeToString(buffer.Bytes()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GET(w http.ResponseWriter, r *http.Request) {
|
||||||
|
secret := gotp.RandomSecret(16)
|
||||||
|
userSession := r.Context().Value("user").(types.User)
|
||||||
|
totp := gotp.NewDefaultTOTP(secret)
|
||||||
|
uri := totp.ProvisioningUri(userSession.Email, "filekeeper")
|
||||||
|
base64Str, err := generateQRCode(uri)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var component templ.Component
|
||||||
|
if r.Header.Get("hx-request") == "true" {
|
||||||
|
component = userTotpSetupView.MainContent("Filekeeper - 2FA Setup Page", base64Str, secret, userSession, types.Message{
|
||||||
|
Code: 3,
|
||||||
|
Message: "",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
component = userTotpSetupView.Main("Filekeeper - 2FA Setup Page", base64Str, secret, userSession, types.Message{
|
||||||
|
Code: 3,
|
||||||
|
Message: "",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err := component.Render(r.Context(), w); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func POST(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
code := r.Form.Get("totp")
|
||||||
|
secret := r.Form.Get("secret")
|
||||||
|
totp := gotp.NewDefaultTOTP(secret)
|
||||||
|
userSession := r.Context().Value("user").(types.User)
|
||||||
|
uri := totp.ProvisioningUri(userSession.Email, "filekeeper")
|
||||||
|
|
||||||
|
base64Str, err := generateQRCode(uri)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var component templ.Component
|
||||||
|
if totp.Verify(code, time.Now().Unix()) {
|
||||||
|
if err := app.Server.Database.InitializeTotp(userSession.Email, secret); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := app.Server.Service.DeleteUser(r.Context(), userSession.Email)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r.Header.Get("hx-request") == "true" {
|
||||||
|
component = userTotpSetupView.MainContent("Filekeeper - 2FA Setup Page", base64Str, secret, userSession, types.Message{
|
||||||
|
Code: 1,
|
||||||
|
Message: "Your TOTP setup is complete! Your account is now more secure.",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
component = userTotpSetupView.Main("Filekeeper - 2FA Setup Page", base64Str, secret, userSession, types.Message{
|
||||||
|
Code: 1,
|
||||||
|
Message: "Your TOTP setup is complete! Your account is now more secure.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := component.Render(r.Context(), w); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if r.Header.Get("hx-request") == "true" {
|
||||||
|
component = userTotpSetupView.MainContent("Filekeeper - 2FA Setup Page", base64Str, secret, userSession, types.Message{
|
||||||
|
Code: 0,
|
||||||
|
Message: "The code you entered is incorrect. Please double-check the code and try again.",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
component = userTotpSetupView.Main("Filekeeper - 2FA Setup Page", base64Str, secret, userSession, types.Message{
|
||||||
|
Code: 0,
|
||||||
|
Message: "The code you entered is incorrect. Please double-check the code and try again.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err := component.Render(r.Context(), w); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
@ -76,7 +76,7 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
usage, err := app.Server.Service.GetUserStorageUsage(r.Context(), userSession.UserID.String())
|
usage, err := app.Server.Service.CalculateUserStorageUsage(r.Context(), userSession.UserID.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
@ -193,11 +193,19 @@ func handlerWS(conn *websocket.Conn, userSession types.User) {
|
|||||||
|
|
||||||
err := app.Server.Database.CreateFile(&newFile)
|
err := app.Server.Database.CreateFile(&newFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
sendErrorResponse(conn, action.Action, "Error Creating File")
|
sendErrorResponse(conn, action.Action, "Error Creating File")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
userFile, err := app.Server.Service.GetUserFile(context.Background(), fileID)
|
err = app.Server.Service.RemoveUserFilesCache(context.Background(), userSession.UserID)
|
||||||
|
if err != nil {
|
||||||
|
app.Server.Logger.Error(err.Error())
|
||||||
|
sendErrorResponse(conn, action.Action, "Error Creating File")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userFile, err := app.Server.Service.GetFileDetail(context.Background(), fileID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
sendErrorResponse(conn, action.Action, "Unknown error")
|
sendErrorResponse(conn, action.Action, "Unknown error")
|
||||||
@ -216,7 +224,7 @@ func handlerWS(conn *websocket.Conn, userSession types.User) {
|
|||||||
sendErrorResponse(conn, action.Action, "File Is Different")
|
sendErrorResponse(conn, action.Action, "File Is Different")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
userFile, err := app.Server.Service.GetUserFile(context.Background(), file.ID)
|
userFile, err := app.Server.Service.GetFileDetail(context.Background(), file.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Server.Logger.Error(err.Error())
|
app.Server.Logger.Error(err.Error())
|
||||||
sendErrorResponse(conn, action.Action, "Unknown error")
|
sendErrorResponse(conn, action.Action, "Unknown error")
|
||||||
|
@ -5,12 +5,20 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/fossyy/filekeeper/app"
|
"github.com/fossyy/filekeeper/app"
|
||||||
"github.com/fossyy/filekeeper/types"
|
"github.com/fossyy/filekeeper/types"
|
||||||
"github.com/fossyy/filekeeper/types/models"
|
"github.com/fossyy/filekeeper/types/models"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"time"
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
UserCacheKey = "UserCache:%s"
|
||||||
|
UserFilesCacheKey = "UserFilesCache:%s"
|
||||||
|
FileCacheKey = "FileCache:%s"
|
||||||
|
FileChunkCacheKey = "FileChunkCache:%s"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
@ -26,7 +34,8 @@ func NewService(db types.Database, cache types.CachingServer) *Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) GetUser(ctx context.Context, email string) (*models.User, error) {
|
func (r *Service) GetUser(ctx context.Context, email string) (*models.User, error) {
|
||||||
userJSON, err := app.Server.Cache.GetCache(ctx, "UserCache:"+email)
|
cacheKey := fmt.Sprintf(UserCacheKey, email)
|
||||||
|
userJSON, err := r.cache.GetCache(ctx, cacheKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, redis.Nil) {
|
if errors.Is(err, redis.Nil) {
|
||||||
userData, err := r.db.GetUser(email)
|
userData, err := r.db.GetUser(email)
|
||||||
@ -43,7 +52,7 @@ func (r *Service) GetUser(ctx context.Context, email string) (*models.User, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
newUserJSON, _ := json.Marshal(user)
|
newUserJSON, _ := json.Marshal(user)
|
||||||
err = r.cache.SetCache(ctx, "UserCache:"+email, newUserJSON, time.Hour*12)
|
err = r.cache.SetCache(ctx, cacheKey, newUserJSON, time.Hour*12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -62,96 +71,132 @@ func (r *Service) GetUser(ctx context.Context, email string) (*models.User, erro
|
|||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) DeleteUser(ctx context.Context, email string) error {
|
func (r *Service) RemoveUserCache(ctx context.Context, email string) error {
|
||||||
err := r.cache.DeleteCache(ctx, "UserCache:"+email)
|
cacheKey := fmt.Sprintf(UserCacheKey, email)
|
||||||
if err != nil {
|
return r.cache.DeleteCache(ctx, cacheKey)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Service) GetUserStorageUsage(ctx context.Context, ownerID string) (uint64, error) {
|
|
||||||
// TODO: Implement GetUserStorageUsage Cache
|
|
||||||
files, err := app.Server.Database.GetFiles(ownerID, "", types.All)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
var total uint64 = 0
|
|
||||||
for _, file := range files {
|
|
||||||
total += file.Size
|
|
||||||
}
|
|
||||||
return total, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) GetFile(ctx context.Context, id string) (*models.File, error) {
|
func (r *Service) GetFile(ctx context.Context, id string) (*models.File, error) {
|
||||||
fileJSON, err := r.cache.GetCache(ctx, "FileCache:"+id)
|
cacheKey := fmt.Sprintf(FileCacheKey, id)
|
||||||
|
fileJSON, err := r.cache.GetCache(ctx, cacheKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, redis.Nil) {
|
if errors.Is(err, redis.Nil) {
|
||||||
uploadData, err := r.db.GetFile(id)
|
fileData, err := r.db.GetFile(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newFileJSON, _ := json.Marshal(uploadData)
|
newFileJSON, _ := json.Marshal(fileData)
|
||||||
err = r.cache.SetCache(ctx, "FileCache:"+id, newFileJSON, time.Hour*24)
|
err = r.cache.SetCache(ctx, cacheKey, newFileJSON, time.Hour*24)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return uploadData, nil
|
return fileData, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileCache models.File
|
var file models.File
|
||||||
err = json.Unmarshal([]byte(fileJSON), &fileCache)
|
err = json.Unmarshal([]byte(fileJSON), &file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &fileCache, nil
|
return &file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) DeleteFileCache(ctx context.Context, id string) error {
|
func (r *Service) RemoveFileCache(ctx context.Context, id string) error {
|
||||||
err := r.cache.DeleteCache(ctx, "FileCache:"+id)
|
cacheKey := fmt.Sprintf(FileCacheKey, id)
|
||||||
if err != nil {
|
return r.cache.DeleteCache(ctx, cacheKey)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) GetFileChunks(ctx context.Context, fileID uuid.UUID, ownerID uuid.UUID, totalChunk uint64) (*types.FileState, error) {
|
func (r *Service) GetUserFiles(ctx context.Context, ownerID uuid.UUID) ([]*models.File, error) {
|
||||||
fileJSON, err := r.cache.GetCache(ctx, "FileChunkCache:"+fileID.String())
|
cacheKey := fmt.Sprintf(UserFilesCacheKey, ownerID.String())
|
||||||
|
filesJSON, err := r.cache.GetCache(ctx, cacheKey)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, redis.Nil) {
|
||||||
|
files, err := r.db.GetFiles(ownerID.String(), "", types.All)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
filesJSON, err := json.Marshal(files)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = r.cache.SetCache(ctx, cacheKey, filesJSON, time.Hour*6)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return files, nil
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var files []*models.File
|
||||||
|
err = json.Unmarshal([]byte(filesJSON), &files)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return files, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Service) RemoveUserFilesCache(ctx context.Context, ownerID uuid.UUID) error {
|
||||||
|
cacheKey := fmt.Sprintf(UserFilesCacheKey, ownerID.String())
|
||||||
|
return r.cache.DeleteCache(ctx, cacheKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Service) CalculateUserStorageUsage(ctx context.Context, ownerID string) (uint64, error) {
|
||||||
|
files, err := r.db.GetFiles(ownerID, "", types.All)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var total uint64
|
||||||
|
for _, file := range files {
|
||||||
|
total += file.Size
|
||||||
|
}
|
||||||
|
|
||||||
|
return total, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Service) GetFileChunks(ctx context.Context, fileID, ownerID uuid.UUID, totalChunk uint64) (*types.FileState, error) {
|
||||||
|
cacheKey := fmt.Sprintf(FileChunkCacheKey, fileID.String())
|
||||||
|
fileJSON, err := r.cache.GetCache(ctx, cacheKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, redis.Nil) {
|
if errors.Is(err, redis.Nil) {
|
||||||
prefix := fmt.Sprintf("%s/%s/chunk_", ownerID.String(), fileID.String())
|
prefix := fmt.Sprintf("%s/%s/chunk_", ownerID.String(), fileID.String())
|
||||||
|
|
||||||
existingChunks, err := app.Server.Storage.ListObjects(ctx, prefix)
|
existingChunks, err := app.Server.Storage.ListObjects(ctx, prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
missingChunk := len(existingChunks) != int(totalChunk)
|
|
||||||
|
|
||||||
newChunkCache := types.FileState{
|
fileState := types.FileState{
|
||||||
Done: !missingChunk,
|
Done: len(existingChunks) == int(totalChunk),
|
||||||
Chunk: make(map[string]bool),
|
Chunk: make(map[string]bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < int(totalChunk); i++ {
|
for i := 0; i < int(totalChunk); i++ {
|
||||||
newChunkCache.Chunk[fmt.Sprintf("chunk_%d", i)] = false
|
fileState.Chunk[fmt.Sprintf("chunk_%d", i)] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, chunkFile := range existingChunks {
|
for _, chunkFile := range existingChunks {
|
||||||
var chunkIndex int
|
var chunkIndex int
|
||||||
fmt.Sscanf(chunkFile, "chunk_%d", &chunkIndex)
|
fmt.Sscanf(chunkFile, "chunk_%d", &chunkIndex)
|
||||||
newChunkCache.Chunk[fmt.Sprintf("chunk_%d", chunkIndex)] = true
|
fileState.Chunk[fmt.Sprintf("chunk_%d", chunkIndex)] = true
|
||||||
}
|
}
|
||||||
newChunkCacheJSON, err := json.Marshal(newChunkCache)
|
|
||||||
|
newChunkCacheJSON, err := json.Marshal(fileState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = r.cache.SetCache(ctx, "FileChunkCache:"+fileID.String(), newChunkCacheJSON, time.Minute*30)
|
err = r.cache.SetCache(ctx, cacheKey, newChunkCacheJSON, time.Minute*30)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &newChunkCache, nil
|
|
||||||
|
return &fileState, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -161,10 +206,11 @@ func (r *Service) GetFileChunks(ctx context.Context, fileID uuid.UUID, ownerID u
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &existingCache, nil
|
return &existingCache, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) UpdateFileChunk(ctx context.Context, fileID uuid.UUID, ownerID uuid.UUID, chunk string, totalChunk uint64) error {
|
func (r *Service) UpdateFileChunk(ctx context.Context, fileID, ownerID uuid.UUID, chunk string, totalChunk uint64) error {
|
||||||
chunks, err := r.GetFileChunks(ctx, fileID, ownerID, totalChunk)
|
chunks, err := r.GetFileChunks(ctx, fileID, ownerID, totalChunk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -175,7 +221,6 @@ func (r *Service) UpdateFileChunk(ctx context.Context, fileID uuid.UUID, ownerID
|
|||||||
|
|
||||||
for i := 0; i < int(totalChunk); i++ {
|
for i := 0; i < int(totalChunk); i++ {
|
||||||
if !chunks.Chunk[fmt.Sprintf("chunk_%d", i)] {
|
if !chunks.Chunk[fmt.Sprintf("chunk_%d", i)] {
|
||||||
fmt.Println("chunk", i, " ", chunks.Chunk[fmt.Sprintf("chunk_%d", i)])
|
|
||||||
chunks.Done = false
|
chunks.Done = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -185,7 +230,9 @@ func (r *Service) UpdateFileChunk(ctx context.Context, fileID uuid.UUID, ownerID
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.cache.SetCache(ctx, "FileChunkCache:"+fileID.String(), updatedChunkCacheJSON, time.Minute*30)
|
|
||||||
|
cacheKey := fmt.Sprintf(FileChunkCacheKey, fileID.String())
|
||||||
|
err = r.cache.SetCache(ctx, cacheKey, updatedChunkCacheJSON, time.Minute*30)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -193,7 +240,7 @@ func (r *Service) UpdateFileChunk(ctx context.Context, fileID uuid.UUID, ownerID
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Service) GetUserFile(ctx context.Context, fileID uuid.UUID) (*types.FileData, error) {
|
func (r *Service) GetFileDetail(ctx context.Context, fileID uuid.UUID) (*types.FileData, error) {
|
||||||
fileData, err := r.GetFile(ctx, fileID.String())
|
fileData, err := r.GetFile(ctx, fileID.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -204,7 +251,7 @@ func (r *Service) GetUserFile(ctx context.Context, fileID uuid.UUID) (*types.Fil
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
data := &types.FileData{
|
return &types.FileData{
|
||||||
ID: fileData.ID,
|
ID: fileData.ID,
|
||||||
OwnerID: fileData.OwnerID,
|
OwnerID: fileData.OwnerID,
|
||||||
Name: fileData.Name,
|
Name: fileData.Name,
|
||||||
@ -217,7 +264,5 @@ func (r *Service) GetUserFile(ctx context.Context, fileID uuid.UUID) (*types.Fil
|
|||||||
Type: fileData.Type,
|
Type: fileData.Type,
|
||||||
Done: chunks.Done,
|
Done: chunks.Done,
|
||||||
Chunk: chunks.Chunk,
|
Chunk: chunks.Chunk,
|
||||||
}
|
}, nil
|
||||||
|
|
||||||
return data, nil
|
|
||||||
}
|
}
|
||||||
|
@ -92,11 +92,13 @@ type CachingServer interface {
|
|||||||
|
|
||||||
type Services interface {
|
type Services interface {
|
||||||
GetUser(ctx context.Context, email string) (*models.User, error)
|
GetUser(ctx context.Context, email string) (*models.User, error)
|
||||||
DeleteUser(ctx context.Context, email string) error
|
RemoveUserCache(ctx context.Context, email string) error
|
||||||
GetFile(ctx context.Context, id string) (*models.File, error)
|
GetFile(ctx context.Context, id string) (*models.File, error)
|
||||||
DeleteFileCache(ctx context.Context, id string) error
|
GetUserFiles(ctx context.Context, ownerID uuid.UUID) ([]*models.File, error)
|
||||||
GetUserFile(ctx context.Context, fileID uuid.UUID) (*FileData, error)
|
RemoveUserFilesCache(ctx context.Context, ownerID uuid.UUID) error
|
||||||
GetUserStorageUsage(ctx context.Context, ownerID string) (uint64, error)
|
RemoveFileCache(ctx context.Context, id string) error
|
||||||
|
GetFileDetail(ctx context.Context, fileID uuid.UUID) (*FileData, error)
|
||||||
|
CalculateUserStorageUsage(ctx context.Context, ownerID string) (uint64, error)
|
||||||
GetFileChunks(ctx context.Context, fileID uuid.UUID, ownerID uuid.UUID, totalChunk uint64) (*FileState, error)
|
GetFileChunks(ctx context.Context, fileID uuid.UUID, ownerID uuid.UUID, totalChunk uint64) (*FileState, error)
|
||||||
UpdateFileChunk(ctx context.Context, fileID uuid.UUID, ownerID uuid.UUID, chunk string, totalChunk uint64) error
|
UpdateFileChunk(ctx context.Context, fileID uuid.UUID, ownerID uuid.UUID, chunk string, totalChunk uint64) error
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ templ Base(title string){
|
|||||||
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
|
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content">
|
|
||||||
@modal()
|
@modal()
|
||||||
|
<div id="content">
|
||||||
{ children... }
|
{ children... }
|
||||||
</div>
|
</div>
|
||||||
@uploadBox()
|
@uploadBox()
|
||||||
@ -41,8 +41,8 @@ templ BaseAuth(title string){
|
|||||||
<script src="/public/main.js"></script>
|
<script src="/public/main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content">
|
|
||||||
@modal()
|
@modal()
|
||||||
|
<div id="content">
|
||||||
{ children... }
|
{ children... }
|
||||||
</div>
|
</div>
|
||||||
@uploadBox()
|
@uploadBox()
|
||||||
|
@ -52,11 +52,15 @@ func Base(title string) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -68,7 +72,7 @@ func Base(title string) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -97,7 +101,7 @@ func BaseAuth(title string) templ.Component {
|
|||||||
templ_7745c5c3_Var3 = templ.NopComponent
|
templ_7745c5c3_Var3 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -110,7 +114,7 @@ func BaseAuth(title string) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -118,11 +122,15 @@ func BaseAuth(title string) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -138,7 +146,7 @@ func BaseAuth(title string) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -167,7 +175,7 @@ func modal() templ.Component {
|
|||||||
templ_7745c5c3_Var5 = templ.NopComponent
|
templ_7745c5c3_Var5 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -196,7 +204,7 @@ func uploadBox() templ.Component {
|
|||||||
templ_7745c5c3_Var6 = templ.NopComponent
|
templ_7745c5c3_Var6 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -225,7 +233,7 @@ func MainScript() templ.Component {
|
|||||||
templ_7745c5c3_Var7 = templ.NopComponent
|
templ_7745c5c3_Var7 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 13)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -254,7 +262,7 @@ func modalScript() templ.Component {
|
|||||||
templ_7745c5c3_Var8 = templ.NopComponent
|
templ_7745c5c3_Var8 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -283,12 +291,12 @@ func Navbar(user types.User) templ.Component {
|
|||||||
templ_7745c5c3_Var9 = templ.NopComponent
|
templ_7745c5c3_Var9 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 13)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if user.Authenticated {
|
if user.Authenticated {
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -301,7 +309,7 @@ func Navbar(user types.User) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 17)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -314,17 +322,17 @@ func Navbar(user types.User) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 18)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 17)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 19)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 18)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 20)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -353,7 +361,7 @@ func Footer() templ.Component {
|
|||||||
templ_7745c5c3_Var12 = templ.NopComponent
|
templ_7745c5c3_Var12 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 19)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 21)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user