mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-06-03 22:02:57 +00:00
44414af085
Introduces a 'thumbnail' field to the Canvas model and updates all storage backends (AWS S3, filesystem, memory, and SQLite) to handle storing and retrieving this field. Also updates the API handler to accept and save the thumbnail, and switches SQLite driver to modernc.org/sqlite for improved compatibility. Updates .gitignore to exclude .db files.
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type (
|
|
// Canvas represents the metadata and content of a user-saved drawing.
|
|
Canvas struct {
|
|
ID string `json:"id"`
|
|
UserID string `json:"-"` // Not exposed in JSON responses, used internally.
|
|
Name string `json:"name"`
|
|
Thumbnail string `json:"thumbnail,omitempty"`
|
|
Data []byte `json:"-"` // The full canvas data, not included in list views.
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
// CanvasStore defines the persistence layer for user-owned canvases.
|
|
// All operations are scoped to a specific user.
|
|
CanvasStore interface {
|
|
// List returns metadata for all canvases owned by a user.
|
|
// The returned Canvas objects should not contain the `Data` field to keep the response light.
|
|
List(ctx context.Context, userID string) ([]*Canvas, error)
|
|
|
|
// Get returns a single canvas by its ID, ensuring it belongs to the user.
|
|
Get(ctx context.Context, userID, id string) (*Canvas, error)
|
|
|
|
// Save creates or updates a canvas for a user.
|
|
Save(ctx context.Context, canvas *Canvas) error
|
|
|
|
// Delete removes a canvas, ensuring it belongs to the user.
|
|
Delete(ctx context.Context, userID, id string) error
|
|
}
|
|
)
|