fix: remove dead code, fold migration 002 into 001, implement error numerics
All checks were successful
check / check (push) Successful in 2m17s
All checks were successful
check / check (push) Successful in 2m17s
- Remove unused GetAwayByNick() from queries.go - Delete migration 002; fold away_message and topic_set_by/topic_set_at columns into migration 001 (pre-1.0 policy: single migration file) - PRIVMSG/NOTICE missing target now sends 411 ERR_NORECIPIENT - PRIVMSG/NOTICE missing body now sends 412 ERR_NOTEXTTOSEND - Non-member channel send now sends 404 ERR_CANNOTSENDTOCHAN - Auth failure now returns 451 ERR_NOTREGISTERED numeric in response - Update test assertions to match correct IRC numerics
This commit is contained in:
@@ -71,11 +71,10 @@ func (hdlr *Handlers) requireAuth(
|
||||
sessionID, clientID, nick, err :=
|
||||
hdlr.authSession(request)
|
||||
if err != nil {
|
||||
hdlr.respondError(
|
||||
writer, request,
|
||||
"unauthorized",
|
||||
http.StatusUnauthorized,
|
||||
)
|
||||
hdlr.respondJSON(writer, request, map[string]any{
|
||||
"error": "not registered",
|
||||
"numeric": irc.ErrNotRegistered,
|
||||
}, http.StatusUnauthorized)
|
||||
|
||||
return 0, 0, "", false
|
||||
}
|
||||
@@ -925,8 +924,8 @@ func (hdlr *Handlers) handlePrivmsg(
|
||||
if target == "" {
|
||||
hdlr.enqueueNumeric(
|
||||
request.Context(), clientID,
|
||||
irc.ErrNeedMoreParams, nick, []string{command},
|
||||
"Not enough parameters",
|
||||
irc.ErrNoRecipient, nick, []string{command},
|
||||
"No recipient given",
|
||||
)
|
||||
hdlr.broker.Notify(sessionID)
|
||||
hdlr.respondJSON(writer, request,
|
||||
@@ -940,8 +939,8 @@ func (hdlr *Handlers) handlePrivmsg(
|
||||
if len(lines) == 0 {
|
||||
hdlr.enqueueNumeric(
|
||||
request.Context(), clientID,
|
||||
irc.ErrNeedMoreParams, nick, []string{command},
|
||||
"Not enough parameters",
|
||||
irc.ErrNoTextToSend, nick, []string{command},
|
||||
"No text to send",
|
||||
)
|
||||
hdlr.broker.Notify(sessionID)
|
||||
hdlr.respondJSON(writer, request,
|
||||
@@ -1028,8 +1027,8 @@ func (hdlr *Handlers) handleChannelMsg(
|
||||
if !isMember {
|
||||
hdlr.respondIRCError(
|
||||
writer, request, clientID, sessionID,
|
||||
irc.ErrNotOnChannel, nick, []string{target},
|
||||
"You're not on that channel",
|
||||
irc.ErrCannotSendToChan, nick, []string{target},
|
||||
"Cannot send to channel",
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
@@ -810,9 +810,9 @@ func TestMessageMissingBody(t *testing.T) {
|
||||
|
||||
msgs, _ := tserver.pollMessages(token, lastID)
|
||||
|
||||
if !findNumeric(msgs, "461") {
|
||||
if !findNumeric(msgs, "412") {
|
||||
t.Fatalf(
|
||||
"expected ERR_NEEDMOREPARAMS (461), got %v",
|
||||
"expected ERR_NOTEXTTOSEND (412), got %v",
|
||||
msgs,
|
||||
)
|
||||
}
|
||||
@@ -834,9 +834,9 @@ func TestMessageMissingTo(t *testing.T) {
|
||||
|
||||
msgs, _ := tserver.pollMessages(token, lastID)
|
||||
|
||||
if !findNumeric(msgs, "461") {
|
||||
if !findNumeric(msgs, "411") {
|
||||
t.Fatalf(
|
||||
"expected ERR_NEEDMOREPARAMS (461), got %v",
|
||||
"expected ERR_NORECIPIENT (411), got %v",
|
||||
msgs,
|
||||
)
|
||||
}
|
||||
@@ -869,9 +869,9 @@ func TestNonMemberCannotSend(t *testing.T) {
|
||||
|
||||
msgs, _ := tserver.pollMessages(aliceToken, lastID)
|
||||
|
||||
if !findNumeric(msgs, "442") {
|
||||
if !findNumeric(msgs, "404") {
|
||||
t.Fatalf(
|
||||
"expected ERR_NOTONCHANNEL (442), got %v",
|
||||
"expected ERR_CANNOTSENDTOCHAN (404), got %v",
|
||||
msgs,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user