mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Client:
- ci.yml: patch auto-generated events.ts to rename Event -> _Event
so @typescript-eslint/no-unused-vars does not fail on generated code
Server (gocritic):
- service/channel.go: rangeValCopy (line 74), elseif (line 174)
- service/message.go: rangeValCopy (line 648), elseif (lines 438, 496)
- ws/emit.go: caseOrder — ChannelEvent before BroadcastAllEvent
- ws/handlers_command_test.go: stringXbytes — use bytes.Equal
- ws/pubsub_test.go: stringXbytes — use bytes.Equal
Server (nilerr):
- service/channel.go: nolint:nilerr for intentional silent drops in HandleTyping
Server (gosec):
- plugin/host_ui.go: G703 nolint — path already sanitized above
- plugin/registry.go: G302 — tighten plugin file permissions 0o640 → 0o600
- ws/hub.go, ws/serve.go: G115 nolint — seq counters never reach MaxInt64
Server (unused/unparam):
- plugin/registry.go: nolint:unused for wazero-tagged module field
- telemetry/metrics.go: nolint:unused for otel-tagged resetAppMetricsForInit
- ws/command.go: nolint:unparam for map entries whose error return is always nil
Server (staticcheck ST1000/ST1020):
- Add blank line before package declarations in phase-comment files
(api/plugins_handler.go, plugin/host_{commands,events,http}.go,
telemetry/metrics.go, telemetry/middleware.go,
telemetry/telemetry_default.go, ws/event_persister.go)
- Fix GlobalTracer/GlobalMeter doc comments to start with function name
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package ws
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
)
|
|
|
|
// EmitEvents routes typed events to the appropriate broadcast methods.
|
|
// Called from readPump goroutines after a V2 handler returns.
|
|
//
|
|
// CRITICAL ordering: SequencedDMEvent MUST be checked before ChannelEvent
|
|
// because DM events implement both interfaces. The SequencedDMEvent path
|
|
// calls sendSequencedToUsers which preserves the seqMu serialization guarantee.
|
|
//
|
|
// VoiceChannelEvent MUST be checked before ExcludeSenderEvent because voice
|
|
// events implement a superset of ExcludeSender semantics but target by voice
|
|
// channel membership rather than channel focus.
|
|
func (h *Hub) EmitEvents(events []Event) {
|
|
for _, ev := range events {
|
|
switch e := ev.(type) {
|
|
case SequencedDMEvent:
|
|
// High priority: DMs are time-sensitive.
|
|
h.sendSequencedToUsersHigh(e.ChannelID(), e.ParticipantIDs(), e.Payload())
|
|
case VoiceChannelGuardedEvent:
|
|
h.sendToUserIfInVoiceChannel(e.VoiceChannelID(), e.TargetUserID(), e.Payload())
|
|
case VoiceChannelEvent:
|
|
h.sendToVoiceChannelExcept(e.VoiceChannelID(), e.ExcludeUserID(), e.Payload())
|
|
case ExcludeSenderEvent:
|
|
// Low priority: typing indicators are ephemeral.
|
|
h.broadcastExcludeLow(e.ChannelID(), e.ExcludeUserID(), e.Payload())
|
|
case UserTargetedEvent:
|
|
// High priority: targeted events (DM opens, mentions).
|
|
h.SendToUserHigh(e.TargetUserID(), e.Payload())
|
|
case ChannelEvent:
|
|
h.BroadcastToChannel(e.ChannelID(), e.Payload())
|
|
case BroadcastAllEvent:
|
|
// Check concrete type: presence is low-priority, others are normal.
|
|
if _, isPresence := ev.(PresenceEvent); isPresence {
|
|
h.BroadcastToAllLow(e.Payload())
|
|
} else {
|
|
h.BroadcastToAll(e.Payload())
|
|
}
|
|
default:
|
|
slog.Warn("EmitEvents: unknown event type", "type", fmt.Sprintf("%T", ev))
|
|
}
|
|
}
|
|
}
|