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:
+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 {
|
||||
|
||||
Reference in New Issue
Block a user