feat(handlers): Add helper methods for hybrid SSR
- Add GetPendingRegistrationsData() to DeviceHandler - Add GetQueueData() to QueueHandler - Add template types: DeviceData, PendingRegistrationData, ConflictData, QueueItemData - Add collection types: CollectionData, CollectionDetailData, BookData All changes are non-breaking and preserve API compatibility
This commit is contained in:
@@ -489,6 +489,31 @@ func (h *DeviceHandler) RejectDevice(c echo.Context) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *DeviceHandler) GetPendingRegistrationsData(c echo.Context) ([]map[string]interface{}, error) {
|
||||
userID := c.Get("user_id").(string)
|
||||
userUUID, err := uuid.Parse(userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
registrations := []map[string]interface{}{}
|
||||
for _, reg := range pendingRegistrations {
|
||||
if reg.UserID == userUUID || reg.UserID == (uuid.UUID{}) {
|
||||
registrations = append(registrations, map[string]interface{}{
|
||||
"registration_id": reg.RegistrationID,
|
||||
"device_name": reg.DeviceName,
|
||||
"device_type": reg.DeviceType,
|
||||
"device_identifier": reg.DeviceIdentifier,
|
||||
"expires_at": reg.ExpiresAt,
|
||||
"created_at": reg.CreatedAt,
|
||||
"is_approved": reg.UserID != (uuid.UUID{}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return registrations, nil
|
||||
}
|
||||
|
||||
func (h *DeviceHandler) ListPendingRegistrations(c echo.Context) error {
|
||||
userID := c.Get("user_id").(string)
|
||||
userUUID, err := uuid.Parse(userID)
|
||||
|
||||
Reference in New Issue
Block a user