Skip to content

Trustroots/nostr-email-notification-daemon

Repository files navigation

Trustroots Nostr Email Contact Tool

Connects to MongoDB to find Trustroots users with nostrNpub set and listen for direct messages on Nostr relays.

Will be redundant when

  1. a working app has push notifications
  2. trustroots is completely decentralized.

For now it's probably a good way to move nostroots forward.

NIP-5 Verification

Important: If a nostr pubkey (npub) is found in our MongoDB database with an associated username, this implies that username@trustroots.org is a valid NIP-5 identifier. The system constructs NIP-5 identifiers directly from the database without performing external NIP-5 lookups at trustroots.org, as the presence of the npub in our database already validates the association.

Setup

Docker (Recommended)

cp env.example .env
cp config.json.example config.json
# Edit config.json with your settings
docker-compose up -d

Local Development

  1. Copy config: cp config.json.example config.json
  2. Install deps: go mod tidy
  3. Edit config.json with the sending npub/nsec keys

Usage

go run main.go                    # Show summary
go run main.go --list-users      # List users in categories  
go run main.go --nostr-listen    # Listen for direct messages
go run main.go --test --send-to-npub <npub> --msg "<message>"  # Send test direct message

Email Preview

Preview how email notifications will look in the browser:

./preview.sh                      # Start preview server
# or
go run preview_server.go          # Alternative way to start

Then open http://localhost:8080 in your browser to see:

  • HTML Direct Message Preview: How encrypted DM notifications look
  • Text Direct Message Preview: Plain text version of DMs

This makes it easy to see how emails will appear to users and test template changes.

Config

{
  "mongodb": {
    "uri": "mongodb://localhost:27017",
    "database": "trustroots"
  },
  "sender-npub": "profile-npub",
  "sender-nsec": "profile-nsec",
  "sender-email": "noreply@trustroots.org",
  "relays": ["wss://relay1.com", "wss://relay2.com"],
  "smtp": {
    "host": "smtp.gmail.com",
    "port": 587,
    "username": "your-email@gmail.com",
    "password": "your-app-password",
    "from_name": "Trustroots Nostr"
  }
}

Docker Commands

docker-compose up -d          # Start
docker-compose logs -f        # View logs
docker-compose down           # Stop
docker-compose restart        # Restart

License

Unlicense - Public Domain

About

Connects to MongoDB to find Trustroots users with nostrNpub set and listen for mentions on Nostr relays.

Resources

License

Stars

Watchers

Forks