Stone.js API
    Preparing search index...
    • Declare a class as a notice: something a person receives.

      The decorator says what it is; the class says what it says. There is no content option, and that is deliberate: a decorator carrying message bodies would put text in the one place it cannot be translated, formatted, or computed from the event. The class answers notify(event, context), and it is built through the container, so it can ask for i18n, a repository, a URL signer.

      With on, nobody calls the notifier. A module emits what happened, and the notice that named that event decides who learns about it. The emitting module imports nothing and is never reopened when a channel is added, which is the whole reason this exists rather than a service call.

      Type Parameters

      • T extends ClassType = ClassType

      Parameters

      Returns ClassDecorator

      A class decorator.

      @Notice({
      name: 'guardianship.consent_needed',
      on: 'identity.guardian.invited.v1',
      channels: ['smtp', 'in-app']
      })
      export class ConsentNeeded {
      constructor ({ i18n }) { this.i18n = i18n }

      recipients (event) { return event.guardianId }

      notify (event, { locale }) {
      return {
      smtp: {
      subject: this.i18n.t('consent.subject', { lng: locale }),
      body: this.i18n.t('consent.body', { lng: locale, child: event.childHandle })
      },
      'in-app': { body: this.i18n.t('consent.short', { lng: locale }) }
      }
      }
      }