refactor: Rename AFTN struct field from "Text" to "Body"

The code changes rename the "Text" field in the AFTN struct to "Body" to improve clarity and consistency. This change aligns with the naming convention used in other parts of the codebase and enhances code readability.
This commit is contained in:
windyboy
2024-07-20 12:37:18 +08:00
parent 74c3768e27
commit d4eabd42e4
5 changed files with 329 additions and 8 deletions
+5 -5
View File
@@ -60,12 +60,12 @@ func (p *AFTNParser) Parse(rawMessage string) (*domain.AFTN, error) {
return nil, err
}
text, bodyType, err := parseTextInfo(strings.Join(lines[3:], "\n"))
body, category, err := extractBodyAndCategory(strings.Join(lines[3:], "\n"))
if err != nil {
return nil, err
}
bodyData, err := p.extractBodyData(text)
bodyData, err := p.extractBodyData(body)
if err != nil {
return nil, err
}
@@ -79,8 +79,8 @@ func (p *AFTNParser) Parse(rawMessage string) (*domain.AFTN, error) {
Header: header,
PriorityAndSender: priorityAndSender,
TimeAndReceiver: timeAndReceiver,
Text: text,
Category: bodyType,
Body: body,
Category: category,
BodyData: aftn,
ReceivedTime: time.Now(),
}, nil
@@ -124,7 +124,7 @@ func parseTimeAndReceiver(line string) (domain.TimeAndReceiver, error) {
}
// parseTextInfo parses the text and extracts the body type from an AFTN message.
func parseTextInfo(text string) (string, string, error) {
func extractBodyAndCategory(text string) (string, string, error) {
match := textPattern.FindStringSubmatch(text)
if len(match) > 1 {
return match[0], match[1], nil