check / check (push) Waiting to run
History was selected by msg_to, so whoever next held a released nick, or created a deleted channel again under its old name, could read the earlier holder's messages. Each message row now records the session a DM or INVITE was sent to (to_session_id) and the channel a channel message was sent to (to_channel_id), and GET /api/v1/history selects by the one that applies, using its index. A session's DM history now also follows it across nick changes. A DM or channel message whose recipient is deleted before it is stored gets the unknown nick or channel error. Model: opus-5-5
31 lines
675 B
Go
31 lines
675 B
Go
package db
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"modernc.org/sqlite"
|
|
sqlite3 "modernc.org/sqlite/lib"
|
|
)
|
|
|
|
// IsUniqueConstraintError reports whether err is a SQLite
|
|
// unique-constraint violation.
|
|
func IsUniqueConstraintError(err error) bool {
|
|
var sqliteErr *sqlite.Error
|
|
if !errors.As(err, &sqliteErr) {
|
|
return false
|
|
}
|
|
|
|
return sqliteErr.Code() == sqlite3.SQLITE_CONSTRAINT_UNIQUE
|
|
}
|
|
|
|
// IsForeignKeyConstraintError reports whether err is a
|
|
// SQLite foreign-key constraint violation.
|
|
func IsForeignKeyConstraintError(err error) bool {
|
|
var sqliteErr *sqlite.Error
|
|
if !errors.As(err, &sqliteErr) {
|
|
return false
|
|
}
|
|
|
|
return sqliteErr.Code() == sqlite3.SQLITE_CONSTRAINT_FOREIGNKEY
|
|
}
|