(name string, body []byte)
| 1313 | } |
| 1314 | |
| 1315 | func formatSyntheticPasteText(name string, body []byte) string { |
| 1316 | const syntheticPasteNameLabel = "Synthetic attachment name: " |
| 1317 | const syntheticPasteNameSuffix = "\n\n" |
| 1318 | |
| 1319 | var sb strings.Builder |
| 1320 | sb.Grow(len(syntheticPasteInlinePrefix) + len(name) + min(len(body), syntheticPasteInlineBudget) + len(syntheticPasteTruncationWarning) + len(syntheticPasteNameLabel) + len(syntheticPasteNameSuffix)) |
| 1321 | _, _ = sb.WriteString(syntheticPasteInlinePrefix) |
| 1322 | if name != "" { |
| 1323 | _, _ = fmt.Fprintf(&sb, "%s%s%s", syntheticPasteNameLabel, name, syntheticPasteNameSuffix) |
| 1324 | } |
| 1325 | _, _ = sb.WriteString(string(body[:min(len(body), syntheticPasteInlineBudget)])) |
| 1326 | if len(body) > syntheticPasteInlineBudget { |
| 1327 | _, _ = sb.WriteString(syntheticPasteTruncationWarning) |
| 1328 | } |
| 1329 | return sb.String() |
| 1330 | } |
| 1331 | |
| 1332 | func formatMissingAttachmentText(mediaType string) string { |
| 1333 | const missingAttachmentBody = "[missing-attachment] The user attached a file here, but the content has expired and is no longer available." |
no test coverage detected