Skip to content

Secured Signal API Implementation#33

Open
pr0ton11 wants to merge 10 commits into
louisho5:mainfrom
pr0ton11:feat/secured-signal-api-integration
Open

Secured Signal API Implementation#33
pr0ton11 wants to merge 10 commits into
louisho5:mainfrom
pr0ton11:feat/secured-signal-api-integration

Conversation

@pr0ton11
Copy link
Copy Markdown

Summary

Adds Signal as a new communication channel for picobot, using the secured-signal-api proxy in front of signal-cli-rest-api.

Architecture decisions

  • WebSocket for inbound messages — connects to ws://<host>/v1/receive/<number> with automatic reconnection (exponential backoff, 1s → 30s). HTTP long-polling was avoided because it destructively consumes messages from the queue, which would break other consumers of the same Signal API instance.
  • HTTP POST for outbound messages — sends via POST /v2/send with Bearer token authentication through the secured-signal-api proxy.
  • No new dependenciesgorilla/websocket was already an indirect dependency (via discordgo); it has been promoted to direct.

What's included

Commit Description
deb48b0 SignalConfig struct and Signal field in config schema
49a298d signal.go — full channel implementation (~300 lines): WS inbound, HTTP outbound, echo suppression, allowFrom filtering, group support, message splitting
f302841 signal_test.go — 8 unit tests covering: empty params validation, WS URL building, round-trip inbound/outbound, group messages, allowFrom filtering, non-data message filtering, echo suppression, Bearer auth verification
5cb9675 Gateway wiring + interactive channels login menu with Signal option (5)
8d1ad77 Docker env var support: SIGNAL_API_URL, SIGNAL_API_TOKEN, SIGNAL_NUMBER, SIGNAL_ALLOW_FROM

Design notes

  • Follows the existing channel convention exactly: StartSignal() accepts (ctx, hub, ...params), calls hub.Subscribe("signal"), launches goroutines for inbound/outbound.
  • Uses the signalSender interface pattern (matching discordSender/slackPoster) for testability — all tests use mock HTTP servers, no real Signal API needed.
  • Reuses the existing splitMessage() helper from discord.go for message chunking.
  • The + in phone numbers is percent-encoded as %2B in the WebSocket URL path, as expected by signal-cli-rest-api (Go's url.PathEscape considers + valid in paths and leaves it literal).

Verification

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... — all pass (8 new Signal tests + all existing tests)

Signed-off-by: Marc Singer <marc@singer.gg>
Signed-off-by: Marc Singer <marc@singer.gg>
Signed-off-by: Marc Singer <marc@singer.gg>
Signed-off-by: Marc Singer <marc@singer.gg>
Signed-off-by: Marc Singer <marc@singer.gg>
@pr0ton11
Copy link
Copy Markdown
Author

@louisho5 may I bother you for a review? Thank you

@louisho5
Copy link
Copy Markdown
Owner

Thanks @pr0ton11 :) It is a really cool suggestion. I will explore it.

@pr0ton11
Copy link
Copy Markdown
Author

I'll fix the linter issues.

Handle error return values from conn.Close(), conn.WriteMessage(), and
startSignalWithSender() properly instead of ignoring them. Errors are
logged in production code and reported via t.Logf/t.Fatalf in tests.

Signed-off-by: Marc Singer <marc@singer.gg>
@pr0ton11
Copy link
Copy Markdown
Author

Done. The linter issues were fixed. @louisho5 Please give it a review.

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