irc: drop needMarshaling from applyChannelModes return values
Not used anymore.
This commit is contained in:
parent
a02a06de0d
commit
f646dc9ff2
13
irc.go
13
irc.go
@ -87,11 +87,7 @@ type channelModes map[byte]string
|
|||||||
// and applies the corresponding channel mode and user membership changes on that channel.
|
// and applies the corresponding channel mode and user membership changes on that channel.
|
||||||
//
|
//
|
||||||
// If ch.modes is nil, channel modes are not updated.
|
// If ch.modes is nil, channel modes are not updated.
|
||||||
//
|
func applyChannelModes(ch *upstreamChannel, modeStr string, arguments []string) error {
|
||||||
// needMarshaling is a list of indexes of mode arguments that represent entities
|
|
||||||
// that must be marshaled when sent downstream.
|
|
||||||
func applyChannelModes(ch *upstreamChannel, modeStr string, arguments []string) (needMarshaling map[int]struct{}, err error) {
|
|
||||||
needMarshaling = make(map[int]struct{}, len(arguments))
|
|
||||||
nextArgument := 0
|
nextArgument := 0
|
||||||
var plusMinus byte
|
var plusMinus byte
|
||||||
outer:
|
outer:
|
||||||
@ -102,13 +98,13 @@ outer:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if plusMinus != '+' && plusMinus != '-' {
|
if plusMinus != '+' && plusMinus != '-' {
|
||||||
return nil, fmt.Errorf("malformed modestring %q: missing plus/minus", modeStr)
|
return fmt.Errorf("malformed modestring %q: missing plus/minus", modeStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, membership := range ch.conn.availableMemberships {
|
for _, membership := range ch.conn.availableMemberships {
|
||||||
if membership.Mode == mode {
|
if membership.Mode == mode {
|
||||||
if nextArgument >= len(arguments) {
|
if nextArgument >= len(arguments) {
|
||||||
return nil, fmt.Errorf("malformed modestring %q: missing mode argument for %c%c", modeStr, plusMinus, mode)
|
return fmt.Errorf("malformed modestring %q: missing mode argument for %c%c", modeStr, plusMinus, mode)
|
||||||
}
|
}
|
||||||
member := arguments[nextArgument]
|
member := arguments[nextArgument]
|
||||||
m := ch.Members.Get(member)
|
m := ch.Members.Get(member)
|
||||||
@ -120,7 +116,6 @@ outer:
|
|||||||
m.Remove(membership)
|
m.Remove(membership)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
needMarshaling[nextArgument] = struct{}{}
|
|
||||||
nextArgument++
|
nextArgument++
|
||||||
continue outer
|
continue outer
|
||||||
}
|
}
|
||||||
@ -157,7 +152,7 @@ outer:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return needMarshaling, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm channelModes) Format() (modeString string, parameters []string) {
|
func (cm channelModes) Format() (modeString string, parameters []string) {
|
||||||
|
@ -1175,7 +1175,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = applyChannelModes(ch, modeStr, msg.Params[2:])
|
err = applyChannelModes(ch, modeStr, msg.Params[2:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1227,7 +1227,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
|||||||
|
|
||||||
firstMode := ch.modes == nil
|
firstMode := ch.modes == nil
|
||||||
ch.modes = make(map[byte]string)
|
ch.modes = make(map[byte]string)
|
||||||
if _, err := applyChannelModes(ch, modeStr, msg.Params[3:]); err != nil {
|
if err := applyChannelModes(ch, modeStr, msg.Params[3:]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user