mirror of
https://github.com/ente-io/ente.git
synced 2025-04-30 19:42:33 +00:00
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package controller
|
|
|
|
import (
|
|
"github.com/ente-io/museum/ente"
|
|
"github.com/ente-io/museum/pkg/utils/auth"
|
|
"github.com/ente-io/stacktrace"
|
|
"github.com/gin-contrib/requestid"
|
|
"github.com/gin-gonic/gin"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (c *CollectionController) GetCastCollection(ctx *gin.Context) (*ente.Collection, error) {
|
|
castCtx := auth.GetCastCtx(ctx)
|
|
collection, err := c.CollectionRepo.Get(castCtx.CollectionID)
|
|
if err != nil {
|
|
return nil, stacktrace.Propagate(err, "")
|
|
}
|
|
if collection.IsDeleted {
|
|
return nil, stacktrace.Propagate(ente.ErrNotFound, "collection is deleted")
|
|
}
|
|
return &collection, nil
|
|
}
|
|
|
|
// GetCastDiff returns the changes in the collections since a timestamp, along with hasMore bool flag.
|
|
func (c *CollectionController) GetCastDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
|
|
castCtx := auth.GetCastCtx(ctx)
|
|
collectionID := castCtx.CollectionID
|
|
reqContextLogger := log.WithFields(log.Fields{
|
|
"collection_id": collectionID,
|
|
"since_time": sinceTime,
|
|
"req_id": requestid.Get(ctx),
|
|
})
|
|
diff, hasMore, err := c.getDiff(collectionID, sinceTime, CollectionDiffLimit, reqContextLogger)
|
|
if err != nil {
|
|
return nil, false, stacktrace.Propagate(err, "")
|
|
}
|
|
// hide private metadata before returning files info in diff
|
|
for idx := range diff {
|
|
if diff[idx].MagicMetadata != nil {
|
|
diff[idx].MagicMetadata = nil
|
|
}
|
|
}
|
|
return diff, hasMore, nil
|
|
}
|