Delete records and stuff
This commit is contained in:
@@ -3,6 +3,9 @@ package data
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/bluesky-social/indigo/atproto/auth/oauth"
|
||||
@@ -10,6 +13,7 @@ import (
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
// Taken from https://github.com/bluesky-social/cookbook/blob/main/go-oauth-cli-app/sqlitestore.go
|
||||
@@ -21,6 +25,7 @@ type SqliteStoreConfig struct {
|
||||
SessionExpiryDuration time.Duration // duration since session creation
|
||||
SessionInactivityDuration time.Duration // duration since last session update
|
||||
AuthRequestExpiryDuration time.Duration // duration since auth request creation
|
||||
Logger *slog.Logger
|
||||
}
|
||||
|
||||
// Implements the [oauth.ClientAuthStore] interface, backed by sqlite via gorm
|
||||
@@ -65,7 +70,14 @@ func NewSqliteStore(cfg *SqliteStoreConfig) (*SqliteStore, error) {
|
||||
return nil, fmt.Errorf("missing AuthRequestExpiryDuration")
|
||||
}
|
||||
|
||||
db, err := gorm.Open(sqlite.Open(cfg.DatabasePath), &gorm.Config{})
|
||||
db, err := gorm.Open(sqlite.Open(cfg.DatabasePath), &gorm.Config{
|
||||
Logger: logger.New(
|
||||
log.New(os.Stdout, "\r\n", log.LstdFlags),
|
||||
logger.Config{
|
||||
IgnoreRecordNotFoundError: true,
|
||||
},
|
||||
),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed opening db: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user