mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +00:00
federationsender/roomserver: don't panic while federation is disabled (#1615)
This commit is contained in:
parent
1ce9c52442
commit
a677a288bd
@ -94,13 +94,20 @@ func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := s.processMessage(*output.NewRoomEvent); err != nil {
|
if err := s.processMessage(*output.NewRoomEvent); err != nil {
|
||||||
// panic rather than continue with an inconsistent database
|
switch err.(type) {
|
||||||
log.WithFields(log.Fields{
|
case *queue.ErrorFederationDisabled:
|
||||||
"event": string(ev.JSON()),
|
log.WithField("error", output.Type).Info(
|
||||||
"add": output.NewRoomEvent.AddsStateEventIDs,
|
err.Error(),
|
||||||
"del": output.NewRoomEvent.RemovesStateEventIDs,
|
)
|
||||||
log.ErrorKey: err,
|
default:
|
||||||
}).Panicf("roomserver output log: write room event failure")
|
// panic rather than continue with an inconsistent database
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"event": string(ev.JSON()),
|
||||||
|
"add": output.NewRoomEvent.AddsStateEventIDs,
|
||||||
|
"del": output.NewRoomEvent.RemovesStateEventIDs,
|
||||||
|
log.ErrorKey: err,
|
||||||
|
}).Panicf("roomserver output log: write room event failure")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -122,13 +122,23 @@ func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *d
|
|||||||
return oq
|
return oq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ErrorFederationDisabled struct {
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ErrorFederationDisabled) Error() string {
|
||||||
|
return e.Message
|
||||||
|
}
|
||||||
|
|
||||||
// SendEvent sends an event to the destinations
|
// SendEvent sends an event to the destinations
|
||||||
func (oqs *OutgoingQueues) SendEvent(
|
func (oqs *OutgoingQueues) SendEvent(
|
||||||
ev *gomatrixserverlib.HeaderedEvent, origin gomatrixserverlib.ServerName,
|
ev *gomatrixserverlib.HeaderedEvent, origin gomatrixserverlib.ServerName,
|
||||||
destinations []gomatrixserverlib.ServerName,
|
destinations []gomatrixserverlib.ServerName,
|
||||||
) error {
|
) error {
|
||||||
if oqs.disabled {
|
if oqs.disabled {
|
||||||
return fmt.Errorf("federation is disabled")
|
return &ErrorFederationDisabled{
|
||||||
|
Message: "Federation disabled",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if origin != oqs.origin {
|
if origin != oqs.origin {
|
||||||
// TODO: Support virtual hosting; gh issue #577.
|
// TODO: Support virtual hosting; gh issue #577.
|
||||||
@ -190,7 +200,9 @@ func (oqs *OutgoingQueues) SendEDU(
|
|||||||
destinations []gomatrixserverlib.ServerName,
|
destinations []gomatrixserverlib.ServerName,
|
||||||
) error {
|
) error {
|
||||||
if oqs.disabled {
|
if oqs.disabled {
|
||||||
return fmt.Errorf("federation is disabled")
|
return &ErrorFederationDisabled{
|
||||||
|
Message: "Federation disabled",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if origin != oqs.origin {
|
if origin != oqs.origin {
|
||||||
// TODO: Support virtual hosting; gh issue #577.
|
// TODO: Support virtual hosting; gh issue #577.
|
||||||
|
Loading…
Reference in New Issue
Block a user