This commit is contained in:
William Rehwinkel 2025-12-13 16:36:43 +01:00 committed by GitHub
commit a832104a15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View file

@ -56,6 +56,7 @@ var (
errConfusableIdentifier = errors.New("This identifier is confusable with one already in use")
errInsufficientPrivs = errors.New("Insufficient privileges")
errInvalidUsername = errors.New("Invalid username")
errInvalidTarget = errors.New("Invalid target")
errFeatureDisabled = errors.New(`That feature is disabled`)
errBanned = errors.New("IP or nickmask banned")
errInvalidParams = utils.ErrInvalidParams

View file

@ -25,6 +25,7 @@ import (
var (
ErrDisallowed = errors.New("disallowed")
ErrDBIsNil = errors.New("db == nil")
)
const (
@ -727,7 +728,7 @@ func (mysql *MySQL) AddDirectMessage(sender, senderAccount, recipient, recipient
// note that accountName is the unfolded name
func (mysql *MySQL) DeleteMsgid(msgid, accountName string) (err error) {
if mysql.db == nil {
return nil
return ErrDBIsNil
}
ctx, cancel := context.WithTimeout(context.Background(), mysql.getTimeout())

View file

@ -6,6 +6,7 @@
package irc
import (
"errors"
"fmt"
"net"
"net/http"
@ -1228,6 +1229,15 @@ func (server *Server) DeleteMessage(target, msgid, accountName string) (err erro
if hist == nil {
err = server.historyDB.DeleteMsgid(msgid, accountName)
if err != nil && errors.Is(err, mysql.ErrDBIsNil) {
/*
hist == nil, and db == nil. We know that the
target was not either a current channel or
client, and persistent storage is not used.
So this is an invalid target. (see #2020)
*/
return errInvalidTarget
}
} else {
count := hist.Delete(func(item *history.Item) bool {
return item.Message.Msgid == msgid && (accountName == "*" || item.AccountName == accountName)