mirror of
https://github.com/Dvorinka/Primora.git
synced 2026-10-28 15:51:23 +00:00
- POST /projects/:id/events accepts client-authored events restricted to
the custom.* namespace — system types can't be spoofed. They flow
through the same publishEvent fan-out: realtime, webhooks, and
event_pattern functions all fire.
- Presence: subscribe/unsubscribe bumps a per-project count and
broadcasts presence.update {online} to the realtime stream only —
deliberately not through publishEvent so webhooks and "*" functions
don't fire on connect noise. GET …/realtime/presence reads the count.
- @primora/client gains publish() and presence(); CLI gains events:send.
Verified live: presence 0->1 on subscribe, presence.update frame
delivered, custom event delivered to SSE + fired a custom.* function,
spoofed document.created rejected 400.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
23 lines
600 B
Go
23 lines
600 B
Go
package services
|
|
|
|
import "testing"
|
|
|
|
func TestCustomEventTypeRe(t *testing.T) {
|
|
good := []string{"custom.ping", "custom.deploy.done", "custom.a", "custom.x-y_z.9"}
|
|
bad := []string{
|
|
"", "custom", "custom.", "document.created", "CUSTOM.ping",
|
|
"custom.Ping", "custom..x", "custom.-x", "custom." + string(rune(0x20)) + "x",
|
|
"custom." + string(make([]byte, 64)),
|
|
}
|
|
for _, s := range good {
|
|
if !customEventTypeRe.MatchString(s) {
|
|
t.Errorf("expected %q to match", s)
|
|
}
|
|
}
|
|
for _, s := range bad {
|
|
if customEventTypeRe.MatchString(s) {
|
|
t.Errorf("expected %q to be rejected", s)
|
|
}
|
|
}
|
|
}
|