Track timestamps server-side
This commit is contained in:
@@ -20,24 +20,20 @@ func SetTimestamp(c echo.Context) error {
|
||||
|
||||
// Define a struct to receive the timestamp from JSON
|
||||
type TimestampRequest struct {
|
||||
Timestamp string `json:"timestamp"`
|
||||
Timestamp float64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
// Parse the request body
|
||||
var req TimestampRequest
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.Errorln(err)
|
||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid request body"})
|
||||
}
|
||||
|
||||
// Validate that timestamp was provided
|
||||
if req.Timestamp == "" {
|
||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Timestamp is required"})
|
||||
}
|
||||
|
||||
// Get database connection
|
||||
db := database.Get()
|
||||
log.Debugln("set video", id, "timestamp:", req.Timestamp)
|
||||
|
||||
// Update the timestamp field with the value from the request
|
||||
db := database.Get()
|
||||
result := db.Model(&originals.Original{}).
|
||||
Where("id = ?", id).
|
||||
Update("timestamp", req.Timestamp)
|
||||
|
Reference in New Issue
Block a user