Skip to content

Commit

Permalink
fix Publishing a node doesn't queue it for indexing #356
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Jan 16, 2025
1 parent 2534c76 commit 9d956f4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/services/library/node_visibility/visibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
"github.com/Southclaws/storyden/app/resources/library/node_children"
"github.com/Southclaws/storyden/app/resources/library/node_querier"
"github.com/Southclaws/storyden/app/resources/library/node_writer"
"github.com/Southclaws/storyden/app/resources/mq"
"github.com/Southclaws/storyden/app/resources/rbac"
"github.com/Southclaws/storyden/app/resources/visibility"
"github.com/Southclaws/storyden/app/services/authentication/session"
"github.com/Southclaws/storyden/internal/infrastructure/pubsub"
)

var errNotAuthorised = fault.Wrap(fault.New("not authorised"), ftag.With(ftag.PermissionDenied))
Expand All @@ -24,19 +26,22 @@ type Controller struct {
nodeQuerier *node_querier.Querier
nodeWriter *node_writer.Writer
nc node_children.Repository
indexQueue pubsub.Topic[mq.IndexNode]
}

func New(
accountQuery *account_querier.Querier,
nodeQuerier *node_querier.Querier,
nodeWriter *node_writer.Writer,
nc node_children.Repository,
indexQueue pubsub.Topic[mq.IndexNode],
) *Controller {
return &Controller{
accountQuery: accountQuery,
nodeQuerier: nodeQuerier,
nodeWriter: nodeWriter,
nc: nc,
indexQueue: indexQueue,
}
}

Expand Down Expand Up @@ -71,7 +76,9 @@ func (m *Controller) ChangeVisibility(ctx context.Context, qk library.QueryKey,
}

if vis == visibility.VisibilityPublished {
// TODO: Emit events, send notifications, etc.
if err := m.indexQueue.Publish(ctx, mq.IndexNode{ID: library.NodeID(n.Mark.ID())}); err != nil {
return nil, fault.Wrap(err, fctx.With(ctx))
}
}

return n, nil
Expand Down

0 comments on commit 9d956f4

Please sign in to comment.