Rename backend code references: Bookmann → Bookhoard
Backend changes: - Update import paths: bookmann/internal → bookhoard/internal - Rename struct fields: BookmannUUID → BookhoardUUID - Update handler function names: mapContentIdToBookmannUUID → mapContentIdToBookhoardUUID - Update HTTP response headers: X-Bookmann-* → X-Bookhoard-* - Update service and middleware references - Update main.go imports and references This is part 2 of the project rename to Bookhoard.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/middleware"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/middleware"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/services"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/services"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -294,7 +294,7 @@ func (h *Handler) AutoLinkBooks(c echo.Context) error {
|
||||
bestMatch := match.Matches[0]
|
||||
|
||||
_, err := h.db.CreateDeviceFileAlias(ctx, database.CreateDeviceFileAliasParams{
|
||||
MediaItemID: pgtype.UUID{Bytes: bestMatch.BookmannUUID, Valid: true},
|
||||
MediaItemID: pgtype.UUID{Bytes: bestMatch.BookhoardUUID, Valid: true},
|
||||
DeviceID: book.DeviceID,
|
||||
FilePath: book.FilePath.String,
|
||||
FileSha256: pgtype.Text{String: "", Valid: false},
|
||||
@@ -304,14 +304,14 @@ func (h *Handler) AutoLinkBooks(c echo.Context) error {
|
||||
if err == nil {
|
||||
h.db.LinkUnlinkedBook(ctx, database.LinkUnlinkedBookParams{
|
||||
ID: book.ID,
|
||||
MediaItemID: pgtype.UUID{Bytes: bestMatch.BookmannUUID, Valid: true},
|
||||
MediaItemID: pgtype.UUID{Bytes: bestMatch.BookhoardUUID, Valid: true},
|
||||
ConfidenceScore: toFloat8(bestMatch.Confidence),
|
||||
})
|
||||
|
||||
results = append(results, map[string]interface{}{
|
||||
"unlinked_book_id": uuid.UUID(book.ID.Bytes).String(),
|
||||
"title": book.Title.String,
|
||||
"matched_media_item_id": bestMatch.BookmannUUID.String(),
|
||||
"matched_media_item_id": bestMatch.BookhoardUUID.String(),
|
||||
"confidence": bestMatch.Confidence,
|
||||
"match_method": bestMatch.MatchMethod,
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/services"
|
||||
wsync "bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/services"
|
||||
wsync "bookhoard/internal/sync"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
@@ -3,7 +3,7 @@ package handlers
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -3,7 +3,7 @@ package handlers
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
wsync "bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
wsync "bookhoard/internal/sync"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/config"
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/config"
|
||||
"bookhoard/internal/database"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/services"
|
||||
wsync "bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/services"
|
||||
wsync "bookhoard/internal/sync"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
+18
-18
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
wsync "bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
wsync "bookhoard/internal/sync"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
@@ -25,9 +25,9 @@ func NewKoboHandler(db *database.Queries, connManager *wsync.ConnectionManager)
|
||||
return &KoboHandler{db: db, connManager: connManager}
|
||||
}
|
||||
|
||||
// mapContentIdToBookmannUUID maps Kobo ContentId to Bookmann UUID with multiple fallback strategies
|
||||
// mapContentIdToBookhoardUUID maps Kobo ContentId to Bookmann UUID with multiple fallback strategies
|
||||
// Phase 6: Enhanced Kobo Sync - ContentId Mapping Logic
|
||||
func (h *KoboHandler) mapContentIdToBookmannUUID(ctx echo.Context, contentId string, deviceID uuid.UUID) (uuid.UUID, error, string) {
|
||||
func (h *KoboHandler) mapContentIdToBookhoardUUID(ctx echo.Context, contentId string, deviceID uuid.UUID) (uuid.UUID, error, string) {
|
||||
// Step 1: Try direct ContentId lookup in device_catalogs table
|
||||
catalog, err := h.db.GetDeviceCatalogByKoboContentId(ctx.Request().Context(), contentId)
|
||||
if err == nil && catalog.ID.Valid {
|
||||
@@ -66,7 +66,7 @@ func (h *KoboHandler) mapContentIdToBookmannUUID(ctx echo.Context, contentId str
|
||||
MediaItemID: pgtype.UUID{Bytes: mediaItem.ID.Bytes, Valid: true},
|
||||
BookmannUuid: pgtype.UUID{Bytes: mediaItem.ID.Bytes, Valid: true},
|
||||
KoboContentID: contentId,
|
||||
ContentIDType: pgtype.Text{String: "bookmann_uuid", Valid: true},
|
||||
ContentIDType: pgtype.Text{String: "bookhoard_uuid", Valid: true},
|
||||
Available: pgtype.Bool{Bool: true, Valid: true},
|
||||
DeliveryDate: pgtype.Timestamptz{Time: time.Now(), Valid: true},
|
||||
DeliveryMethod: pgtype.Text{String: "sync", Valid: true},
|
||||
@@ -79,11 +79,11 @@ func (h *KoboHandler) mapContentIdToBookmannUUID(ctx echo.Context, contentId str
|
||||
return uuid.Nil, fmt.Errorf("unlinked book: ContentId %s not found", contentId), "unlinked"
|
||||
}
|
||||
|
||||
// mapBookmannUUIDToKoboContentId maps Bookmann UUID to Kobo ContentId
|
||||
// mapBookhoardUUIDToKoboContentId maps Bookmann UUID to Kobo ContentId
|
||||
// Creates new entry in device_catalogs if not exists
|
||||
func (h *KoboHandler) mapBookmannUUIDToKoboContentId(c echo.Context, bookmannUUID uuid.UUID, deviceID uuid.UUID) (string, error) {
|
||||
func (h *KoboHandler) mapBookhoardUUIDToKoboContentId(c echo.Context, bookmannUUID uuid.UUID, deviceID uuid.UUID) (string, error) {
|
||||
// Check if catalog entry already exists
|
||||
catalog, err := h.db.GetDeviceCatalogByBookmannUUID(c.Request().Context(), database.GetDeviceCatalogByBookmannUUIDParams{
|
||||
catalog, err := h.db.GetDeviceCatalogByBookhoardUUID(c.Request().Context(), database.GetDeviceCatalogByBookhoardUUIDParams{
|
||||
DeviceID: pgtype.UUID{Bytes: deviceID, Valid: true},
|
||||
BookmannUuid: pgtype.UUID{Bytes: bookmannUUID, Valid: true},
|
||||
})
|
||||
@@ -102,7 +102,7 @@ func (h *KoboHandler) mapBookmannUUIDToKoboContentId(c echo.Context, bookmannUUI
|
||||
// 2. Use existing entitlement_id from media_items
|
||||
// 3. Generate new "kobo_" prefixed UUID
|
||||
var koboContentId string
|
||||
contentIdType := "bookmann_generated"
|
||||
contentIdType := "bookhoard_generated"
|
||||
|
||||
if mediaItem.KoboContentID.Valid && mediaItem.KoboContentID.String != "" {
|
||||
koboContentId = mediaItem.KoboContentID.String
|
||||
@@ -226,7 +226,7 @@ type KoboLibraryBook struct {
|
||||
MimeType string `json:"MimeType"`
|
||||
FileSize int64 `json:"FileSize"`
|
||||
Categories []string `json:"Categories,omitempty"`
|
||||
BookmannUUID string `json:"BookmannUUID,omitempty"`
|
||||
BookhoardUUID string `json:"BookhoardUUID,omitempty"`
|
||||
}
|
||||
|
||||
type KoboLibraryResponse struct {
|
||||
@@ -319,7 +319,7 @@ func (h *KoboHandler) Initialization(c echo.Context) error {
|
||||
}
|
||||
|
||||
// Phase 6: Use ContentId mapping instead of direct UUID
|
||||
koboContentId, err := h.mapBookmannUUIDToKoboContentId(c, bookmannUUID, deviceUUID)
|
||||
koboContentId, err := h.mapBookhoardUUIDToKoboContentId(c, bookmannUUID, deviceUUID)
|
||||
if err != nil {
|
||||
// Fallback to entitlement_id or generate new one
|
||||
if item.EntitlementID.Valid && item.EntitlementID.String != "" {
|
||||
@@ -361,7 +361,7 @@ func (h *KoboHandler) Initialization(c echo.Context) error {
|
||||
MimeType: mimeType,
|
||||
FileSize: fileSize,
|
||||
Categories: collections,
|
||||
BookmannUUID: bookmannUUID.String(),
|
||||
BookhoardUUID: bookmannUUID.String(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ func (h *KoboHandler) Markup(c echo.Context) error {
|
||||
|
||||
for _, readingSync := range req.ReadingSync {
|
||||
// Phase 6: Use ContentId mapping with fallback logic
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookmannUUID(c, readingSync.ContentId, deviceUUID)
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookhoardUUID(c, readingSync.ContentId, deviceUUID)
|
||||
if err != nil {
|
||||
// Unlinked book detected
|
||||
unlinkedBooks++
|
||||
@@ -434,7 +434,7 @@ func (h *KoboHandler) Markup(c echo.Context) error {
|
||||
|
||||
for _, bookmarkSync := range req.BookmarkSync {
|
||||
// Phase 6: Use ContentId mapping with fallback logic
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookmannUUID(c, bookmarkSync.ContentId, deviceUUID)
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookhoardUUID(c, bookmarkSync.ContentId, deviceUUID)
|
||||
if err != nil {
|
||||
// Unlinked book - skip
|
||||
continue
|
||||
@@ -512,7 +512,7 @@ func (h *KoboHandler) Bookmark(c echo.Context) error {
|
||||
|
||||
for _, bookmarkSync := range req.BookmarkSync {
|
||||
// Phase 6: Use ContentId mapping with fallback logic
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookmannUUID(c, bookmarkSync.ContentId, deviceUUID)
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookhoardUUID(c, bookmarkSync.ContentId, deviceUUID)
|
||||
if err != nil {
|
||||
// Unlinked book - skip
|
||||
continue
|
||||
@@ -577,7 +577,7 @@ func (h *KoboHandler) AnalyticsGettests(c echo.Context) error {
|
||||
|
||||
for _, test := range req {
|
||||
// Phase 6: Use ContentId mapping with fallback logic
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookmannUUID(c, test.ContentId, deviceUUID)
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookhoardUUID(c, test.ContentId, deviceUUID)
|
||||
if err != nil {
|
||||
// Unlinked book - skip
|
||||
continue
|
||||
@@ -654,7 +654,7 @@ func (h *KoboHandler) SyncFromServer(c echo.Context) error {
|
||||
|
||||
for _, syncData := range req {
|
||||
// Phase 6: Use ContentId mapping with fallback logic
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookmannUUID(c, syncData.ContentId, deviceUUID)
|
||||
bookmannUUID, err, _ := h.mapContentIdToBookhoardUUID(c, syncData.ContentId, deviceUUID)
|
||||
if err != nil {
|
||||
// Unlinked book - skip
|
||||
continue
|
||||
@@ -669,7 +669,7 @@ func (h *KoboHandler) SyncFromServer(c echo.Context) error {
|
||||
UserID: pgUserID,
|
||||
Percentage: pgtype.Float8{Float64: percentage, Valid: true},
|
||||
LastSyncDevice: pgtype.Text{String: "kobo", Valid: true},
|
||||
LastSyncSource: pgtype.Text{String: "bookmann", Valid: true},
|
||||
LastSyncSource: pgtype.Text{String: "bookhoard", Valid: true},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
wsync "bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
wsync "bookhoard/internal/sync"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/services"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/services"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
|
||||
+10
-10
@@ -1,9 +1,9 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/opds"
|
||||
"bookmann/internal/services"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/opds"
|
||||
"bookhoard/internal/services"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
@@ -137,7 +137,7 @@ func (h *OPDSHandler) GetDeviceCatalog(c echo.Context) error {
|
||||
// Create OPDS feed
|
||||
feed := opds.NewFeed(
|
||||
fmt.Sprintf("urn:uuid:%s", deviceID),
|
||||
"Bookmann Library",
|
||||
"Bookhoard Library",
|
||||
)
|
||||
|
||||
// Add feed links
|
||||
@@ -187,7 +187,7 @@ func (h *OPDSHandler) GetDeviceCatalog(c echo.Context) error {
|
||||
|
||||
// Add SHA-256 metadata
|
||||
if item.FileSha256.Valid {
|
||||
entry.AddMetadata("bookmann:sha256", item.FileSha256.String)
|
||||
entry.AddMetadata("bookhoard:sha256", item.FileSha256.String)
|
||||
}
|
||||
|
||||
// Add collections as categories
|
||||
@@ -305,7 +305,7 @@ func (h *OPDSHandler) SearchDeviceCatalog(c echo.Context) error {
|
||||
entry.SetIdentifier(bookUUID)
|
||||
|
||||
if item.FileSha256.Valid {
|
||||
entry.AddMetadata("bookmann:sha256", item.FileSha256.String)
|
||||
entry.AddMetadata("bookhoard:sha256", item.FileSha256.String)
|
||||
}
|
||||
|
||||
collections, err := h.db.GetCollectionsForBook(c.Request().Context(), pgtype.UUID{Bytes: item.ID.Bytes, Valid: true})
|
||||
@@ -466,12 +466,12 @@ func (h *OPDSHandler) DownloadBook(c echo.Context) error {
|
||||
filename := filepath.Base(filePath)
|
||||
c.Response().Header().Set("Content-Type", mimeType)
|
||||
c.Response().Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
|
||||
c.Response().Header().Set("X-Bookmann-UUID", bookUUID.String())
|
||||
c.Response().Header().Set("X-Bookhoard-UUID", bookUUID.String())
|
||||
|
||||
if format == "kepub" && fileSha256 != "" {
|
||||
c.Response().Header().Set("X-Bookmann-KEPUB-SHA256", fileSha256)
|
||||
c.Response().Header().Set("X-Bookhoard-KEPUB-SHA256", fileSha256)
|
||||
} else if fileSha256 != "" {
|
||||
c.Response().Header().Set("X-Bookmann-SHA256", fileSha256)
|
||||
c.Response().Header().Set("X-Bookhoard-SHA256", fileSha256)
|
||||
}
|
||||
|
||||
// Stream file
|
||||
@@ -595,7 +595,7 @@ func (h *OPDSHandler) GetDeviceNavigation(c echo.Context) error {
|
||||
// Create OPDS navigation feed
|
||||
feed := opds.NewFeed(
|
||||
fmt.Sprintf("urn:uuid:%s", deviceID),
|
||||
"Bookmann Library Navigation",
|
||||
"Bookhoard Library Navigation",
|
||||
)
|
||||
|
||||
// Add feed links
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
wsync "bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
wsync "bookhoard/internal/sync"
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -22,7 +22,7 @@ func NewSidecarHandler(db *database.Queries) *SidecarHandler {
|
||||
|
||||
type SidecarConfig struct {
|
||||
Version string `json:"version"`
|
||||
Bookmann SidecarBookmannConfig `json:"bookmann"`
|
||||
Bookmann SidecarBookmannConfig `json:"bookhoard"`
|
||||
Books map[string]SidecarBook `json:"books"`
|
||||
Collections []SidecarCollection `json:"collections"`
|
||||
OPDSEnabled bool `json:"opds_enabled"`
|
||||
@@ -40,7 +40,7 @@ type SidecarBookmannConfig struct {
|
||||
}
|
||||
|
||||
type SidecarBook struct {
|
||||
BookmannUUID string `json:"bookmann_uuid"`
|
||||
BookhoardUUID string `json:"bookhoard_uuid"`
|
||||
Title string `json:"title"`
|
||||
Author string `json:"author"`
|
||||
AvailableFormats []string `json:"available_formats"`
|
||||
@@ -119,7 +119,7 @@ func (h *SidecarHandler) GetSidecarConfig(c echo.Context) error {
|
||||
}
|
||||
|
||||
books[key] = SidecarBook{
|
||||
BookmannUUID: bookUUID,
|
||||
BookhoardUUID: bookUUID,
|
||||
Title: item.Title,
|
||||
Author: author,
|
||||
AvailableFormats: availableFormats,
|
||||
@@ -254,7 +254,7 @@ func (h *SidecarHandler) DownloadSidecarConfig(c echo.Context) error {
|
||||
}
|
||||
|
||||
books[key] = SidecarBook{
|
||||
BookmannUUID: bookUUID,
|
||||
BookhoardUUID: bookUUID,
|
||||
Title: item.Title,
|
||||
Author: author,
|
||||
AvailableFormats: availableFormats,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookhoard/internal/database"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"bookmann/internal/database"
|
||||
"bookmann/internal/middleware"
|
||||
"bookmann/internal/sync"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/middleware"
|
||||
"bookhoard/internal/sync"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
Reference in New Issue
Block a user