feat: add user credentials management and health monitoring features
- Implemented CredentialsDialog for updating user credentials. - Created auth store with functions for managing authentication state. - Added HealthWidget to display server health status. - Introduced health monitoring functionality with polling. - Developed AppShell layout to manage authentication and loading states. - Added SettingsDialog for user preferences including theme and language. - Created utility functions for list management and data fetching. - Implemented dashboard view mode preferences. - Integrated search functionality for filtering lists. - Established theme management with local storage support. - Added utility functions for class name management. - Configured SvelteKit for static site generation with fallback. - Set up Vite for development with proxy support for API calls. - Created About and List detail pages with data fetching and display. - Added favicon and updated project configuration files.
This commit is contained in:
1 parent
a4a3eeb5cc
commit
6c1ea2da47
80 files changed
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
type queryExecutor interface {
|
||||
Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
|
||||
}
|
||||
|
||||
func notificationID() string {
|
||||
buffer := make([]byte, 16)
|
||||
if _, err := rand.Read(buffer); err == nil {
|
||||
return hex.EncodeToString(buffer)
|
||||
}
|
||||
return fmt.Sprintf("%d", time.Now().UnixNano())
|
||||
}
|
||||
|
||||
func enqueueNotification(
|
||||
ctx context.Context,
|
||||
executor queryExecutor,
|
||||
deviceID string,
|
||||
eventType string,
|
||||
entityType string,
|
||||
entityID string,
|
||||
listID string,
|
||||
createdAt int64,
|
||||
) error {
|
||||
_, err := executor.Exec(ctx, `
|
||||
INSERT INTO notifications
|
||||
(id, deviceidorigin, eventtype, entitytype, entityid, listid, createdat)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
`, notificationID(), nullableString(deviceID), eventType, entityType, nullableString(entityID), nullableString(listID), createdAt)
|
||||
return err
|
||||
}
|
||||
|
||||
func nullableString(value string) any {
|
||||
if value == "" {
|
||||
return nil
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func ignoreNotificationError(err error) {
|
||||
if err != nil {
|
||||
// Notifications are an acceleration path for clients that poll. A failed
|
||||
// notification must never roll back the data mutation that produced it.
|
||||
fmt.Printf("[notifications] enqueue failed: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func isNoRows(err error) bool {
|
||||
return err == pgx.ErrNoRows
|
||||
}
|
||||
Reference in new issue
Block a user