refactor: replace HTTP error codes with IRC numeric replies #56
Reference in New Issue
Block a user
Delete Branch "feature/irc-numeric-replies"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Refactors all IRC command handlers to respond with proper IRC numeric replies via the message queue instead of HTTP status codes.
HTTP error codes are now reserved exclusively for transport-level concerns:
IRC Numerics Implemented
Success replies (delivered via message queue on success):
Error replies (delivered via message queue instead of HTTP 4xx):
Database Changes
paramscolumn to messages table for IRC-style parametersParamsfield toIRCMessagestructInsertMessageto accept paramsTest Updates
TestWelcomeNumeric,TestJoinNumericsClient Impact
closes #54
Code Review — PR #56: Replace HTTP error codes with IRC numeric replies
Verdict: ✅ PASS
Checklist
enqueueNumeric()pattern used consistentlyparamscolumn correctlydocker build .passesImplementation Quality
Architecture: Clean separation between HTTP transport errors and IRC protocol errors. The
respondIRCErrorhelper centralizes the pattern of enqueue-numeric → notify-broker → respond-HTTP-200. All IRC command errors are now delivered via the message queue as proper numeric replies, exactly as issue #54 requested.Numerics implemented:
Tests: Two new tests added (
TestWelcomeNumeric,TestJoinNumerics). All existing error tests updated from checking HTTP 4xx status codes to checking HTTP 200 + polling the message queue for the correct IRC numeric. This is more thorough testing, not less.PRIVMSG/NOTICE: HTTP response changed from 201 Created to 200 OK, which is correct — all IRC commands now uniformly return 200.
Database:
paramscolumn added to messages table (schema001_initial.sql),InsertMessagesignature updated,PollMessagesandqueryHistoryqueries updated to select/scan the new column. Pre-1.0 migration approach (modify existing migration) follows repo policy.Minor Observations (non-blocking)
deliverJoinNumericscallsGetChannelByNameredundantly (channel ID is already passed as parameter), then usesListChannelsto find the topic — slightly inefficient but correct.respondIRCErrorhelper is used in some places while the same pattern is inlined in others (e.g.,handlePrivmsgmissing target/body, unknown command, handleDirectMsg user not found). Could be cleaned up for consistency in a follow-up.Branch is already up to date with
main. No rebase needed.