mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
increase max cap line length
Workaround for #661: this makes the `CAP LS 302` line from the default config fit on a single line, as long as the server name is at most 35 characters.
This commit is contained in:
parent
a75d26a46b
commit
ae9aecbbb0
4 changed files with 20 additions and 12 deletions
|
|
@ -89,12 +89,15 @@ func (s *Set) Empty() bool {
|
|||
return utils.BitsetEmpty(s[:])
|
||||
}
|
||||
|
||||
const maxPayloadLength = 440
|
||||
const defaultMaxPayloadLength = 450
|
||||
|
||||
// Strings returns all of our enabled capabilities as a slice of strings.
|
||||
func (s *Set) Strings(version Version, values Values) (result []string) {
|
||||
func (s *Set) Strings(version Version, values Values, maxLen int) (result []string) {
|
||||
if maxLen == 0 {
|
||||
maxLen = defaultMaxPayloadLength
|
||||
}
|
||||
var t utils.TokenLineBuilder
|
||||
t.Initialize(maxPayloadLength, " ")
|
||||
t.Initialize(maxLen, " ")
|
||||
|
||||
var capab Capability
|
||||
asSlice := s[:]
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ func TestSets(t *testing.T) {
|
|||
values := make(Values)
|
||||
values[InviteNotify] = "invitemepls"
|
||||
|
||||
actualCap301ValuesString := s1.Strings(Cap301, values)
|
||||
actualCap301ValuesString := s1.Strings(Cap301, values, 0)
|
||||
expectedCap301ValuesString := []string{"invite-notify userhost-in-names"}
|
||||
if !reflect.DeepEqual(actualCap301ValuesString, expectedCap301ValuesString) {
|
||||
t.Errorf("Generated Cap301 values string [%v] did not match expected values string [%v]", actualCap301ValuesString, expectedCap301ValuesString)
|
||||
}
|
||||
|
||||
actualCap302ValuesString := s1.Strings(Cap302, values)
|
||||
actualCap302ValuesString := s1.Strings(Cap302, values, 0)
|
||||
expectedCap302ValuesString := []string{"invite-notify=invitemepls userhost-in-names"}
|
||||
if !reflect.DeepEqual(actualCap302ValuesString, expectedCap302ValuesString) {
|
||||
t.Errorf("Generated Cap302 values string [%s] did not match expected values string [%s]", actualCap302ValuesString, expectedCap302ValuesString)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue