0.16.0 • Published 1 year ago

alkemio-notifications v0.16.0

Weekly downloads
-
License
EUPL-1.2
Repository
github
Last release
1 year ago

notifications

Alkemio out-of-band notifications service.

Build Status Coverage Status BCH compliance Deploy to DockerHub

To test

  1. Start quickstart-services from the server repo with defaults.
  2. Start mailslurper:
npm run start:services
  1. Go to http://localhost:15672/#/queues/%2F/alkemio-notifications.
  2. Under publish message, go to properties and add a new property with name content_type and value application/json.
  3. Select payload:
{
  "data": "YOUR_DATA"
}
  1. Click publish.
  2. Navigate to http://localhost:5051/mailcount. You will see mailCount > 0 (mailslurper will reset the count on each restart).
  3. Navigate to http://localhost:5051/mail. Search for YOUR_DATA. You will find it in the mail message.

Templates

To add a template:

  1. Create a file under src/templates.
  2. Copy welcome.js
  3. Change the template name
  4. Define your channels. You can use this as an example.
  5. In the file you want to use the template, import nunjucks and notifme-template.
  6. Render your template
const notification = await render('template_name', payload, 'en-US');
  1. Send notification
await notifmeSdk.send(notification.channels).then(console.log);

To test the welcome (sample) template, you can use the following payload in RabbitMQ Management UI

{
  "pattern": "communityApplicationCreated",
  "data": {
    "applicantionCreatorID": "f0a47bad-eca5-4942-84ac-4dc9f085b7b8",
    "applicantID": "f0a47bad-eca5-4942-84ac-4dc9f085b7b8",
    "community": {
      "name": "02 Zero Hunger",
      "type": "challenge"
    },
    "space": {
      "id": "32818605-ef2f-4395-bb49-1dc2835c23de",
      "challenge": {
        "id": "7b86f954-d8c3-4fac-a652-b922c80e5c20",
        "opportunity": {
          "id": "636be60f-b64a-4742-8b50-69e608601935"
        }
      }
    }
  }
}

Note: replace applicantionCreatorID, applicantID, and space + challenge + opportunity IDs with IDs you have in your database. You can run the following gql queries to find them:

query {
  spaces {
    id
    displayName
    challenges {
      id
      displayName
      nameID
      community {
        id
        displayName
      }
      opportunities {
        displayName
        id
      }
    }
  }
}
query {
  me {
    id
  }
}