ssube/isolex

consistent context overrides (redirect)

ssube opened this issue · 0 comments

ssube commented

Multiple services need to override parts of an outgoing command or message's context:

  • the completion controller has a defaultTarget
  • the echo controller has a defaultTarget and forceChannel
  • the base generator has a defaultContext and defaultTarget
  • the express listener has a defaultTarget
  • the loopback listener has a defaultTarget and needs a forceChannel

Many of these implement the same new Context({...defaults, ...options, ...force}) structure.

Extract that into a helper that will provide defaults and overrides to a Context. It needs to set the:

  • channel: ChannelData (id and thread)
  • name: string (user display name)
  • source: source: boolean | service: ServiceMetadata (default: source: true)
  • target: source: boolean | service: ServiceMetadata (default: source: true)
  • user: User (which sets name and uid)

Scope

  • add ContextRedirect interface
  • add redirectContext(...): Context helper
    • Context, ContextRedirect args: from incoming entity and config
    • services: ServiceModule, source: Listener = undefined args: service module for source/target metadata lookups, source for source = true redirects
  • ensure name/uid is set
  • look up User from uid? would be async
  • refactor existing services
  • update example config
  • fix tests
  • update docs
  • add new interfaces to schema