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:
@@ -34,7 +34,7 @@ import (
|
||||
)
|
||||
|
||||
// Kinds is the phase-1 channel set (mirrors the NotificationChannel CHECK).
|
||||
var Kinds = []string{"email", "slack", "matrix", "telegram"}
|
||||
var Kinds = []string{"email", "slack", "matrix", "telegram", "signal"}
|
||||
|
||||
// ValidKind reports whether kind is a known channel kind.
|
||||
func ValidKind(kind string) bool {
|
||||
@@ -52,6 +52,10 @@ var secretFields = map[string][]string{
|
||||
"slack": {"webhookUrl"},
|
||||
"matrix": {"accessToken"},
|
||||
"telegram": {"botToken"},
|
||||
// The signal-cli REST bridge authenticates by sender account on the
|
||||
// query string; treat the account identifier as a secret (masked,
|
||||
// encrypted at rest) like every other credential.
|
||||
"signal": {"account"},
|
||||
}
|
||||
|
||||
// MaskValue replaces a secret in API output. A PATCH carrying this exact
|
||||
@@ -111,6 +115,16 @@ func ValidateConfig(kind string, cfg map[string]string) error {
|
||||
if req("chatId") == "" {
|
||||
return errors.New("chatId is required")
|
||||
}
|
||||
case "signal":
|
||||
if err := absURL("restUrl", req("restUrl")); err != nil {
|
||||
return err
|
||||
}
|
||||
if req("account") == "" {
|
||||
return errors.New("account is required")
|
||||
}
|
||||
if req("recipient") == "" {
|
||||
return errors.New("recipient is required")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -254,6 +268,16 @@ func Send(ctx context.Context, d *db.DB, ch Channel, title, body string) error {
|
||||
case "telegram":
|
||||
endpoint := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", url.PathEscape(ch.Config["botToken"]))
|
||||
return postJSON(ctx, endpoint, nil, map[string]any{"chat_id": ch.Config["chatId"], "text": text}, []int{200})
|
||||
case "signal":
|
||||
// signal-cli REST bridge contract: POST {restUrl}/v2/send?account=...
|
||||
// with {"message":..., "recipients":[...]}. The bridge is a
|
||||
// house-style LAN/service dependency, so the dial is netguarded
|
||||
// like every other webhook (private ranges need the test escape
|
||||
// hatch or an operator pin, exactly as SMTP relays do).
|
||||
endpoint := strings.TrimRight(ch.Config["restUrl"], "/") + "/v2/send?account=" + url.QueryEscape(ch.Config["account"])
|
||||
return postJSON(ctx, endpoint, nil, map[string]any{
|
||||
"message": text, "recipients": []string{ch.Config["recipient"]},
|
||||
}, []int{200, 201, 204})
|
||||
}
|
||||
return fmt.Errorf("unknown channel kind %q", ch.Kind)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user