Initial commit: Open sourcing all of the Maple Open Technologies code.

This commit is contained in:
Bartlomiej Mika 2025-12-02 14:33:08 -05:00
commit 755d54a99d
2010 changed files with 448675 additions and 0 deletions

View file

@ -0,0 +1,38 @@
// monorepo/cloud/maplefile-backend/internal/maplefile/repo/filemetadata/check.go
package filemetadata
import (
"fmt"
"github.com/gocql/gocql"
)
func (impl *fileMetadataRepositoryImpl) CheckIfExistsByID(id gocql.UUID) (bool, error) {
var count int
query := `SELECT COUNT(*) FROM maplefile.files_by_id WHERE id = ?`
if err := impl.Session.Query(query, id).Scan(&count); err != nil {
return false, fmt.Errorf("failed to check file existence: %w", err)
}
return count > 0, nil
}
func (impl *fileMetadataRepositoryImpl) CheckIfUserHasAccess(fileID gocql.UUID, userID gocql.UUID) (bool, error) {
// Check if user has access via the user sync table
var count int
query := `SELECT COUNT(*) FROM maplefile.files_by_user
WHERE user_id = ? AND id = ? LIMIT 1 ALLOW FILTERING`
err := impl.Session.Query(query, userID, fileID).Scan(&count)
if err != nil {
if err == gocql.ErrNotFound {
return false, nil
}
return false, fmt.Errorf("failed to check file access: %w", err)
}
return count > 0, nil
}