feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"pageswiki/internal/calendar"
|
||||
)
|
||||
|
||||
// NewCalendarRepository selects the explicit index backend. Calendar files
|
||||
// remain canonical; this does not enable native application bootstrap or HA.
|
||||
func (s *Store) NewCalendarRepository(ctx context.Context) (*calendar.Repository, error) {
|
||||
if s.DocumentRoot == "" {
|
||||
return nil, ErrDocumentStoreRequired
|
||||
}
|
||||
root := filepath.Join(s.DocumentRoot, "calendars")
|
||||
var r *calendar.Repository
|
||||
var err error
|
||||
if s.sqlBackend == storePostgreSQL {
|
||||
r, err = calendar.NewPostgreSQL(ctx, root, s.DB)
|
||||
} else {
|
||||
r, err = calendar.New(root, s.DB)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.PublicAllowed = func(domain string) bool {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
var allowed bool
|
||||
err := s.DB.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM locality_publication_policies p JOIN domains d ON d.uuid=p.domain_uuid AND d.enabled=1 JOIN campuses campus ON campus.uuid=d.campus_uuid AND campus.enabled=1 JOIN config c ON c.domain_uuid=p.domain_uuid AND c.key='authorization_mode' AND c.value='enforcing' WHERE p.domain_uuid=`+s.sqlParam(1)+` AND p.node_kind='domain' AND p.node_uuid=p.domain_uuid AND p.policy='public')`, domain).Scan(&allowed)
|
||||
return err == nil && allowed
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
Reference in new issue
Block a user