Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Latest commit

 

History

History

notifications

origin_github_banner

Head to https://www.originprotocol.com/developers to learn more about what we're building and how to get involved.

Origin Notifications Server

This service is capable of contacting users on various channels. Right now it supports email, browser push, and mobile push.

Messages are normally triggered by a POST to the /events endpoint on this server. See the test directory for examples manually triggering messages for testing.

Options

  • --override-email or env var OVERRIDE_EMAIL : Email which will recieve all emails. This can be useful for testing on live data where you want to see what emails users would receive.
  • --fromEmail or env var SENDGRID_FROM_EMAIL : Email from which messages are sent
  • --asmGroupId or env var ASM_GROUP_ID : SendGrid ASM group for handling unsubscribes.
  • --email-file-out or env var EMAIL_FILE_OUT : Write emails also to files, using this directory+prefix. e.g. "emails/finalized"

Typical debug invocation

export LOG_LEVEL=DEBUG

./node_modules/.bin/nodemon src/app.js \
  --override-email=stan@originprotocol.com \

Browser Notifcations (Old)

See #806 👊

Getting Started

The Easy Way

We recommend running Origin Box to simplify the process of configuring and running all of the modules within the Origin Monorepo.

The Not-As-Easy Way

If you're interested in running just the notifications service (and the event listener) without messaging, attestations, etc, here are some suggestions for making that happen:

In origin-notifications...

  • Install and run PostgreSQL
  • Run npm install web-push -g
  • Run web-push generate-vapid-keys
  • Add database url, email address, public and private keys to origin-notifications/.env
DATABASE_URL=postgresql://localhost/notification
VAPID_EMAIL_ADDRESS=XXXXXXXXXX-your-email-address-XXXXXXXXXX
VAPID_PRIVATE_KEY=XXXXXXXXXX-your-private-key-XXXXXXXXXX
VAPID_PUBLIC_KEY=XXXXXXXXXX-your-public-key-XXXXXXXXXX
  • Run createdb notification
  • Run npm install -g sequelize-cli
  • Run sequelize db:migrate
  • Run npm run start:development

NOTE: VAPID key is for web-push. More detail here.

In origin-dapp...

  • Add public key and notifications url to origin-dapp/.env
NOTIFICATIONS_KEY=XXXXXXXXXX-your-public-key-XXXXXXXXXX
NOTIFICATIONS_URL=http://localhost:3456/
  • Run npm start

In origin-discovery...

  • Add variables to origin-discovery/.env
AFFILIATE_ACCOUNT=0x821aea9a577a9b44299b9c15c88cf3087f3b5544
ARBITRATOR_ACCOUNT=0x0d1d4e623d10f9fba5db95830f7d3839406c6af2
BLOCK_EPOCH=0
DATABASE_URL=postgresql://localhost/discovery
NETWORK_ID=999
IPFS_URL=http://localhost:8080/
WEB3_URL=http://localhost:8545/
  • Run node src/listener/listener.js --continue-file=continue --notifications-webhook=http://localhost:3456/events

(From time to time, you may need to rm continue in origin-discovery.)

To test in the DApp...

  1. Create a listing
  2. Enable notifications
  3. Make an offer from a different account

For more (outdated) information, see the original pull request.

Eventlistener

For local testing, these options are usual for testing against rinkeby network.

export DATABASE_URL=postgresql://origin@localhost/origin

npm run start:listener:development -- --identity --growth --marketplace \
  --network=rinkeby \
  --continue-file=../continue \
  --notifications-webhook=http://localhost:3456/events \
  --verbose
```