Fix provisioning over new store
This commit is contained in:
parent
f31b9bc3a3
commit
4e2f9fdfcd
@ -228,11 +228,11 @@ func (app *CortezaApp) Provision(ctx context.Context) (err error) {
|
||||
ctx = auth.SetSuperUserContext(ctx)
|
||||
|
||||
if err = system.Provision(ctx, app.Log, app.Store); err != nil {
|
||||
return fmt.Errorf("could not provision messaging: %w", err)
|
||||
return fmt.Errorf("could not provision system: %w", err)
|
||||
}
|
||||
|
||||
if err = compose.Provision(ctx, app.Log); err != nil {
|
||||
return fmt.Errorf("could not provision messaging: %w", err)
|
||||
return fmt.Errorf("could not provision compose: %w", err)
|
||||
}
|
||||
|
||||
if err = messaging.Provision(ctx, app.Log); err != nil {
|
||||
|
||||
@ -3,8 +3,6 @@ package importer
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
"github.com/cortezaproject/corteza-server/pkg/deinterfacer"
|
||||
"github.com/cortezaproject/corteza-server/pkg/importer"
|
||||
@ -87,6 +85,7 @@ func (imp *Importer) Cast(def interface{}) (err error) {
|
||||
var nsHandle string
|
||||
// Solving a special case where namespace is defined as string
|
||||
// and we're treating value as namespace's handle
|
||||
println("provisioning namespaces")
|
||||
deinterfacer.KVsetString(&nsHandle, "namespace", def)
|
||||
if nsHandle != "" {
|
||||
delete(def.(map[interface{}]interface{}), "namespace")
|
||||
@ -140,7 +139,7 @@ func (imp *Importer) Store(
|
||||
if imp.namespaces != nil {
|
||||
err = imp.namespaces.Store(ctx, nsStore, mStore, cStore, pStore, rStore)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not import namespaces")
|
||||
return fmt.Errorf("could not import namespaces: %w", err)
|
||||
}
|
||||
|
||||
}
|
||||
@ -154,7 +153,7 @@ func (imp *Importer) Store(
|
||||
|
||||
err = imp.permissions.Store(ctx, pk)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not import permissions")
|
||||
return fmt.Errorf("could not import permissions: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -80,14 +80,14 @@ func (imp *Importer) Store(ctx context.Context, rk channelKeeper, pk permissions
|
||||
|
||||
err = imp.permissions.Store(ctx, pk)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("could not provision permissions: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if imp.settings != nil {
|
||||
err = imp.settings.Store(ctx, sk)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("could not provision settings: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,11 +38,20 @@ func (s Store) convertMessagingChannelFilter(f types.ChannelFilter) (query squir
|
||||
|
||||
if f.CurrentUserID > 0 {
|
||||
qcm := s.SelectBuilder(s.messagingChannelMemberTable("mcm"), "mcm.rel_channel").
|
||||
Where(squirrel.Eq{"cmc.rel_user:": f.CurrentUserID})
|
||||
// minor squirrel quirk: change placeholder format to question
|
||||
// on sub-queries. This will be reset to the right format internally
|
||||
// when merged with main query
|
||||
PlaceholderFormat(squirrel.Question).
|
||||
Where(squirrel.Eq{"mcm.rel_user": f.CurrentUserID})
|
||||
|
||||
qcmSql, qcmArgs, err := qcm.ToSql()
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
|
||||
query = query.Where(squirrel.Or{
|
||||
squirrel.Eq{"c.type": types.ChannelTypePublic},
|
||||
squirrel.Eq{"c.id": qcm},
|
||||
squirrel.Eq{"mch.type": types.ChannelTypePublic},
|
||||
squirrel.Expr("mch.id IN ("+qcmSql+")", qcmArgs...),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ func (imp *Importer) Store(
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("could not provision permissions: %w", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user