From 47ac8e984f3d41dfc77a3feb4623324b55271028 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 26 Dec 2019 22:54:00 -0500 Subject: [PATCH] remove unnecessary helper --- irc/channel.go | 11 ----------- irc/handlers.go | 8 ++++---- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 0eb4e51d..25afdd72 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1055,17 +1055,6 @@ func msgCommandToHistType(command string) (history.ItemType, error) { } } -func histTypeToMsgCommand(t history.ItemType) string { - switch t { - case history.Notice: - return "NOTICE" - case history.Tagmsg: - return "TAGMSG" - default: - return "PRIVMSG" - } -} - func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mode, clientOnlyTags map[string]string, client *Client, message utils.SplitMessage, rb *ResponseBuffer) { histType, err := msgCommandToHistType(command) if err != nil { diff --git a/irc/handlers.go b/irc/handlers.go index 8fe748de..db6d2da8 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -545,10 +545,11 @@ func batchHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res histType, err := msgCommandToHistType(batch.command) if err != nil { histType = history.Privmsg + batch.command = "PRIVMSG" } // see previous caution about modifying ResponseBuffer.Label rb.Label = batch.responseLabel - dispatchMessageToTarget(client, batch.tags, histType, batch.target, batch.message, rb) + dispatchMessageToTarget(client, batch.tags, histType, batch.command, batch.target, batch.message, rb) } } @@ -2137,14 +2138,13 @@ func messageHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R } // each target gets distinct msgids splitMsg := utils.MakeSplitMessage(message, !rb.session.capabilities.Has(caps.MaxLine)) - dispatchMessageToTarget(client, clientOnlyTags, histType, targetString, splitMsg, rb) + dispatchMessageToTarget(client, clientOnlyTags, histType, msg.Command, targetString, splitMsg, rb) } return false } -func dispatchMessageToTarget(client *Client, tags map[string]string, histType history.ItemType, target string, message utils.SplitMessage, rb *ResponseBuffer) { +func dispatchMessageToTarget(client *Client, tags map[string]string, histType history.ItemType, command, target string, message utils.SplitMessage, rb *ResponseBuffer) { server := client.server - command := histTypeToMsgCommand(histType) prefixes, target := modes.SplitChannelMembershipPrefixes(target) lowestPrefix := modes.GetLowestChannelModePrefix(prefixes)