Skip to content

Add offline linked-node owner email notifier - #66

Merged
aledefra merged 3 commits into
developfrom
feat/offline-linked-node-owner-notifier
Jun 10, 2026
Merged

Add offline linked-node owner email notifier#66
aledefra merged 3 commits into
developfrom
feat/offline-linked-node-owner-notifier

Conversation

@aledefra

@aledefra aledefra commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add cron-driven offline linked-node owner notifier flow
  • fetch nodes from oracle nodes_list, filter nodes offline for more than 24h, and resolve owners only via Reader getNdNodesOwners
  • group offline nodes by owner and send one digest email per owner (alias + address + offline duration)
  • enforce cross-node per-owner 24h throttling through CStore (fail closed when CStore is unavailable)
  • add new offline-node email template and wire template/cache accessors
  • add config support for OraclesApi across network configs

Behavior

  • only sends to accounts with confirmed email
  • no send if CStore cannot be reached
  • updates CStore timestamp only after successful send
  • at most one notification per owner every 24h

Verification

  • GOCACHE=/private/tmp/ratio1-go-cache go test ./service -run 'TestFetchOracleNodesListFiltersOfflineNodes|TestNotifyOfflineLinkedNodes' -count=1
  • GOCACHE=/private/tmp/ratio1-go-cache go test ./templates -run 'TestTemplateGetters' -count=1

Copilot AI review requested due to automatic review settings May 8, 2026 11:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an offline linked-node owner notification flow that periodically checks oracle node status, resolves node owners via the Reader contract, throttles notifications via CStore, and sends a per-owner digest email using a new HTML template.

Changes:

  • Added offline linked-node notifier service with CStore-backed per-owner 24h throttling plus unit tests.
  • Added “nodes offline” email template, template loader/getter, and wired email sending in the email service.
  • Extended config to include OraclesApi and per-node OfflineNodesCronJobTiming, and started a new cron job in cmd/main.go.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
templates/util.go Adds template filename constant + loader for the new offline-nodes email template.
templates/html/email.nodes.offline.html Introduces the HTML email template for offline linked-node digests.
templates/cache.go Caches and exposes a getter for the new offline-nodes template.
templates/cache_test.go Extends template cache tests and sets template path for tests.
service/offlineNodesNotifier.go Implements oracle fetch + offline filtering + owner resolution + CStore throttling + email send.
service/offlineNodesNotifier_test.go Adds tests for offline filtering, grouping, throttling, and fail-closed behavior.
service/emailService.go Adds subject + SendOfflineNodesEmail + offline duration formatting.
config/config.testnet.json Adds OraclesApi value.
config/config.devnet.json Adds OraclesApi value.
config/config.mainnet.json Adds OraclesApi and OfflineNodesCronJobTiming schedules.
config/config.go Adds config fields + getter for OfflineNodesCronJobTiming.
cmd/main.go Starts the offline-nodes notifier cron job when configured for the node.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/cache_test.go
Comment on lines 4 to 12
"testing"

"github.com/NaeuralEdgeProtocol/ratio1-backend/config"
"github.com/stretchr/testify/require"
)

func init() {
config.Config.EmailTemplatesPath = "../templates/html/"
LoadAndCacheTemplates()
@aledefra
aledefra force-pushed the feat/offline-linked-node-owner-notifier branch from d893e79 to 703fa8a Compare June 9, 2026 16:24
Copilot AI review requested due to automatic review settings June 10, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Comment on lines +135 to +146
nodesByOwner := make(map[string][]OfflineNodeAlert)
for nodeAddress, ownerAddress := range ownersByNode {
owner := strings.TrimSpace(ownerAddress)
if owner == "" || strings.EqualFold(owner, "0x0000000000000000000000000000000000000000") {
continue
}
node, found := nodeByAddress[strings.ToLower(strings.TrimSpace(nodeAddress))]
if !found {
continue
}
nodesByOwner[owner] = append(nodesByOwner[owner], node)
}
Comment on lines +180 to +188
sentCount := 0
for _, email := range emails {
err = sendOfflineNodesEmailFn(email, ownerNodes)
if err != nil {
log.Error("offline nodes notifier failed to send email to %s: %s", email, err.Error())
continue
}
sentCount++
}
@aledefra
aledefra merged commit 2dbbdae into develop Jun 10, 2026
1 check passed
@aledefra
aledefra deleted the feat/offline-linked-node-owner-notifier branch June 10, 2026 13:55
cristibleotiu added a commit that referenced this pull request Jun 10, 2026
Add offline linked-node owner email notifier (#66)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants