Correctly count article bytes in OVER

This commit is contained in:
ChronosX88 2022-02-05 22:00:30 +03:00
parent b148a434c9
commit 5edc89b9ef
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A

View File

@ -2,6 +2,7 @@ package server
import ( import (
"bufio" "bufio"
"bytes"
"database/sql" "database/sql"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -797,7 +798,16 @@ func (h *Handler) handleOver(s *Session, command string, arguments []string, id
dw.Write([]byte(v.Header.Get("Message-ID") + " ")) dw.Write([]byte(v.Header.Get("Message-ID") + " "))
dw.Write([]byte(v.Header.Get("References") + " ")) dw.Write([]byte(v.Header.Get("References") + " "))
bytesMetadata := len([]byte(v.Body)) // count bytes for message
m := utils.NewMessage()
for k, v := range v.Header {
m.SetHeader(k, v...)
}
m.SetBody("text/plain", v.Body) // FIXME currently only plain text is supported
b := bytes.NewBuffer([]byte{})
m.WriteTo(b)
bytesMetadata := b.Len()
linesMetadata := strings.Count(v.Body, "\n") linesMetadata := strings.Count(v.Body, "\n")
dw.Write([]byte(strconv.Itoa(bytesMetadata) + " ")) dw.Write([]byte(strconv.Itoa(bytesMetadata) + " "))