From c3808bbe892fe1ae62c9c00e0c244517c49b917c Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 3 Dec 2023 21:46:14 -0800 Subject: [PATCH] Fix a null pointer exception if a DM partner goes offline --- pkg/handlers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/handlers.go b/pkg/handlers.go index 849cb62..c861b9c 100644 --- a/pkg/handlers.go +++ b/pkg/handlers.go @@ -207,6 +207,10 @@ func (s *Server) OnMessage(sub *Subscriber, msg messages.Message) { if err == nil && rcpt.Mutes(sub.Username) && !sub.IsAdmin() { log.Debug("Do not send message to %s: they have muted or booted %s", rcpt.Username, sub.Username) return + } else if err != nil { + // Recipient was no longer online: the message won't be sent. + sub.ChatServer("Could not deliver your message: %s appears not to be online.", msg.Channel) + return } // If the sender already mutes the recipient, reply back with the error.