Notifications phase 2 (Gitea #10): share triggers, targeted people, Signal, managed-by footer

- share_received trigger: scanner fires when a bookmark, tag or collection
  is shared with the rule owner (same dedupe discipline; sharer name and
  item title in the message)
- config.targetUserIds on rules: same-tenant targets (<=20, validated at
  write time); each targeted Notification row carries recipientId and is
  delivered through the RECIPIENT's own enabled channel of the rule's kind,
  gated by the recipient's tenant plan (no channel => suppressed, visible
  in history); history lists rows you own or were targeted on
- signal channel kind: signal-cli REST bridge (POST {restUrl}/v2/send with
  account query param and recipients array); account encrypted + masked
  like every other credential; netguard-dialed like every webhook
- 'Managed by David's Superbrain.' footer is plan DATA: entitlements
  ManagedFooter (free hosted plan only; managed_footer override key),
  appended at delivery time - paying plans, core and self-hosted never
  carry it
- catalog: signal joins standard/premium/core/selfhosted channel lists
- migration 019 + schema.sql (trigger/kind CHECKs, Notification.recipientId)
- UI: trigger option, same-tenant target picker via /api/users/search,
  signal channel fields, targeted-count badge on rules
- tests: share/target/footer/signal legs against fake webhook, fake SMTP
  and a fake signal-cli bridge; entitlements footer assertions
This commit is contained in:
Andrew S Erwin
2026-11-09 17:42:38 -06:00
parent c2e2f54fbc
commit 3b11ac83fc
10 changed files with 676 additions and 60 deletions
+16 -5
View File
@@ -57,6 +57,11 @@ type Limits struct {
// (-1 unlimited). Evaluation rate limits live in the engine; this is
// the storage-side plan differentiator.
AITasks int64
// ManagedFooter requires the "Managed by David's Superbrain." footer
// on outbound notifications (Gitea #10): paying plans (standard and
// up, plus core) and self-hosted operators do not carry it; the free
// hosted plan does.
ManagedFooter bool
}
// catalog is the shipped plan matrix (PLAN_PRICING_TIERS.md). Editing a
@@ -71,12 +76,13 @@ var catalog = map[Plan]Limits{
Connectors: []string{"url", "file", "carddav"},
AIMode: "byo",
AITasks: 2,
ManagedFooter: true,
},
PlanStandard: {
StorageBytes: 25 * 1024 * 1024 * 1024,
BrainLinks: 10,
Seats: Unlimited,
NotificationChannels: []string{"email", "slack", "matrix"},
NotificationChannels: []string{"email", "slack", "matrix", "signal"},
Connectors: []string{"url", "file", "carddav", "google", "office365", "nextcloud", "webdav", "caldav", "gmail"},
AIMode: "byo",
AITasks: 10,
@@ -85,7 +91,7 @@ var catalog = map[Plan]Limits{
StorageBytes: 100 * 1024 * 1024 * 1024,
BrainLinks: Unlimited,
Seats: Unlimited,
NotificationChannels: []string{"email", "slack", "matrix", "telegram"},
NotificationChannels: []string{"email", "slack", "matrix", "signal", "telegram"},
Connectors: []string{"url", "file", "carddav", "google", "office365", "nextcloud", "webdav", "caldav", "gmail", "oidc"},
AIMode: "credits",
AITasks: 50,
@@ -94,7 +100,7 @@ var catalog = map[Plan]Limits{
StorageBytes: Unlimited, // storage on Core
BrainLinks: Unlimited,
Seats: Unlimited,
NotificationChannels: []string{"email", "slack", "matrix", "telegram", "talk"},
NotificationChannels: []string{"email", "slack", "matrix", "signal", "telegram", "talk"},
Connectors: []string{"url", "file", "carddav", "google", "office365", "nextcloud", "webdav", "caldav", "gmail", "oidc", "mcp-core"},
AIMode: "core",
AITasks: Unlimited,
@@ -103,7 +109,7 @@ var catalog = map[Plan]Limits{
StorageBytes: Unlimited, // limits are the operator's hardware
BrainLinks: Unlimited,
Seats: Unlimited,
NotificationChannels: []string{"email", "slack", "matrix", "telegram"},
NotificationChannels: []string{"email", "slack", "matrix", "signal", "telegram"},
Connectors: []string{"url", "file", "carddav", "google", "office365", "nextcloud", "webdav", "caldav", "gmail", "oidc"},
AIMode: "byo",
AITasks: Unlimited,
@@ -162,6 +168,7 @@ const (
KeyConnectors = "connectors"
KeyAIMode = "ai_mode"
KeyAITasks = "ai_tasks"
KeyManagedFooter = "managed_footer"
)
// ValidOverrideKey reports whether k is a known TenantEntitlement key.
@@ -169,7 +176,7 @@ const (
// READING ignores unknown keys so rows from a newer version stay harmless.
func ValidOverrideKey(k string) bool {
switch k {
case KeyStorageBytes, KeyBrainLinks, KeySeats, KeyNotificationChannels, KeyConnectors, KeyAIMode, KeyAITasks:
case KeyStorageBytes, KeyBrainLinks, KeySeats, KeyNotificationChannels, KeyConnectors, KeyAIMode, KeyAITasks, KeyManagedFooter:
return true
}
return false
@@ -208,6 +215,10 @@ func ApplyOverrides(l Limits, overrides map[string]string) Limits {
case "byo", "credits", "core":
l.AIMode = v
}
case KeyManagedFooter:
if b, err := strconv.ParseBool(v); err == nil {
l.ManagedFooter = b
}
}
}
return l
@@ -41,6 +41,21 @@ func TestCatalogAndFailClosed(t *testing.T) {
}
}
func TestManagedFooter(t *testing.T) {
if !For(PlanFree).ManagedFooter {
t.Fatal("free plan must carry the managed-by footer")
}
for _, p := range []Plan{PlanStandard, PlanPremium, PlanCore, PlanSelfHosted} {
if For(p).ManagedFooter {
t.Fatalf("plan %s must not carry the footer", p)
}
}
l := ApplyOverrides(For(PlanFree), map[string]string{KeyManagedFooter: "false"})
if l.ManagedFooter {
t.Fatal("managed_footer override did not apply")
}
}
func TestDefaultPlanForTier(t *testing.T) {
if DefaultPlanForTier("core") != PlanCore {
t.Fatal("core tier must derive the core plan")