Files
phylum/server/internal/core/fs/shared.go
2025-05-07 09:57:26 +05:30

21 lines
592 B
Go

package fs
import (
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
)
func (f filesystem) SharedResources(excluded pgtype.UUID) ([]Resource, error) {
const q = `SELECT r.*, (SELECT ` + publinkFieldsQuery + ` FROM publinks l WHERE l.root = r.id) as links FROM resources r
WHERE grants ? $1::TEXT
AND r.id != $2::UUID
AND deleted IS NULL
AND (grants -> $1::TEXT -> 'p')::INTEGER <> 0
ORDER BY grants -> $1::TEXT -> 't' DESC`
if rows, err := f.db.Query(q, f.username, excluded); err != nil {
return nil, err
} else {
return pgx.CollectRows(rows, f.scanLinkedResource)
}
}