diff --git a/pkg/document/document.go b/pkg/document/document.go index ad4f8164d..2e92eced7 100644 --- a/pkg/document/document.go +++ b/pkg/document/document.go @@ -384,7 +384,7 @@ func (d *Document) BroadcastRequests() <-chan BroadcastRequest { // Broadcast encodes the payload and makes a "Broadcast" type request. func (d *Document) Broadcast(eventType string, payload any) error { - if eventType == "document" { + if isEventTypeReserved(eventType) { return ErrReservedEventType } @@ -407,7 +407,7 @@ func (d *Document) SubscribeBroadcastEvent( eventType string, handler func(eventType, publisher string, payload []byte) error, ) error { - if eventType == "document" { + if isEventTypeReserved(eventType) { return ErrReservedEventType } @@ -425,7 +425,7 @@ func (d *Document) SubscribeBroadcastEvent( func (d *Document) UnsubscribeBroadcastEvent( eventType string, ) error { - if eventType == "document" { + if isEventTypeReserved(eventType) { return ErrReservedEventType } @@ -460,3 +460,10 @@ func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { } return "" } + +func isEventTypeReserved(eventType string) bool { + if eventType == "document" { + return true + } + return false +}