notes

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoteNotFound     = errors.New("note not found")
	ErrInvalidPassword  = errors.New("invalid password")
	ErrNoteNotEncrypted = errors.New("note is not encrypted")
)

Functions

func CloseDB

func CloseDB() error

func InitDB

func InitDB(database *sql.DB) error

func ListTags

func ListTags(ctx context.Context) ([]string, error)

func PermanentDeleteNoteByID

func PermanentDeleteNoteByID(ctx context.Context, ID int64) error

func RestoreNoteByID

func RestoreNoteByID(ctx context.Context, ID int64) error

func SoftDeleteNoteByID

func SoftDeleteNoteByID(ctx context.Context, ID int64) error

Types

type Encryptor

type Encryptor interface {
	Encrypt(plaintext []byte) (salt, nonce, ciphertext []byte, err error)
	Decrypt(salt, nonce, ciphertext []byte) ([]byte, error)
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(uploadsDir string) *Handler

func (*Handler) CreateNote

func (h *Handler) CreateNote(c *echo.Context) error

func (*Handler) CreatePrivateNote

func (h *Handler) CreatePrivateNote(c *echo.Context) error

func (*Handler) DecryptNote

func (h *Handler) DecryptNote(c *echo.Context) error

func (*Handler) DeleteNote

func (h *Handler) DeleteNote(c *echo.Context) error

func (*Handler) GetNote

func (h *Handler) GetNote(c *echo.Context) error

func (*Handler) ListArchive

func (h *Handler) ListArchive(c *echo.Context) error

func (*Handler) ListNotes

func (h *Handler) ListNotes(c *echo.Context) error

func (*Handler) PermanentDeleteNote

func (h *Handler) PermanentDeleteNote(c *echo.Context) error

func (*Handler) RestoreNote

func (h *Handler) RestoreNote(c *echo.Context) error

func (*Handler) ShowCreateForm

func (h *Handler) ShowCreateForm(c *echo.Context) error

func (*Handler) ShowEditForm

func (h *Handler) ShowEditForm(c *echo.Context) error

func (*Handler) ShowPrivateCreateForm

func (h *Handler) ShowPrivateCreateForm(c *echo.Context) error

func (*Handler) TogglePinNote

func (h *Handler) TogglePinNote(c *echo.Context) error

func (*Handler) UnlockPrivateEditForm

func (h *Handler) UnlockPrivateEditForm(c *echo.Context) error

func (*Handler) UpdateNote

func (h *Handler) UpdateNote(c *echo.Context) error

type ListParams

type ListParams struct {
	Query         string
	Tag           string
	Sort          string // "created_at", "updated_at", "title"
	Order         string // "asc", "desc"
	EncryptedOnly bool
	Page          int
	PageSize      int
}

type ListResult

type ListResult struct {
	Notes      []Note
	Total      int
	Page       int
	PageSize   int
	TotalPages int
	HasPrev    bool
	HasNext    bool
	PrevPage   int
	NextPage   int
}

func ListNotes

func ListNotes(ctx context.Context, p ListParams) (ListResult, error)

type Note

type Note struct {
	ID          int64
	Title       string
	Content     string
	ImageData   string
	Tags        []string
	IsPinned    bool
	IsEncrypted bool
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   *time.Time
}

func AddNote

func AddNote(ctx context.Context, title, content, imageData, tags string) (Note, error)

func AddPrivateNote

func AddPrivateNote(ctx context.Context, title, content, imageData, password string) (Note, error)

func DecryptNoteByID

func DecryptNoteByID(ctx context.Context, ID int64, password string) (Note, error)

func GetNoteByID

func GetNoteByID(ctx context.Context, ID int64) (Note, error)

func ListArchivedNotes

func ListArchivedNotes(ctx context.Context) ([]Note, error)

func TogglePinNoteByID

func TogglePinNoteByID(ctx context.Context, ID int64) (Note, error)

func UpdateNoteByID

func UpdateNoteByID(ctx context.Context, ID int64, title, content, imageData string) (Note, error)

func UpdatePrivateNoteByID

func UpdatePrivateNoteByID(ctx context.Context, ID int64, title, content, imageData, currentPassword, newPassword string) (Note, error)

type PasswordEncryptor

type PasswordEncryptor struct {
	// contains filtered or unexported fields
}

func NewPasswordEncryptor

func NewPasswordEncryptor(password string) *PasswordEncryptor

func (*PasswordEncryptor) Decrypt

func (p *PasswordEncryptor) Decrypt(salt, nonce, ciphertext []byte) ([]byte, error)

func (*PasswordEncryptor) Encrypt

func (p *PasswordEncryptor) Encrypt(plaintext []byte) (salt, nonce, ciphertext []byte, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL