| 3233 | } |
| 3234 | |
| 3235 | func nativeNetworkThreadPromotionDigest( |
| 3236 | messages []store.NetworkConversationMessage, |
| 3237 | originMessageID string, |
| 3238 | ) (string, []string, bool) { |
| 3239 | target := strings.TrimSpace(originMessageID) |
| 3240 | sourceIDs := make([]string, 0, len(messages)) |
| 3241 | var builder strings.Builder |
| 3242 | found := false |
| 3243 | for _, message := range messages { |
| 3244 | messageID := strings.TrimSpace(message.MessageID) |
| 3245 | if messageID == "" { |
| 3246 | continue |
| 3247 | } |
| 3248 | sourceIDs = append(sourceIDs, messageID) |
| 3249 | if messageID == target { |
| 3250 | found = true |
| 3251 | } |
| 3252 | if builder.Len() >= 4000 { |
| 3253 | continue |
| 3254 | } |
| 3255 | line := nativeNetworkThreadPromotionMessageLine(message) |
| 3256 | if line == "" { |
| 3257 | continue |
| 3258 | } |
| 3259 | if builder.Len() > 0 { |
| 3260 | builder.WriteByte('\n') |
| 3261 | } |
| 3262 | builder.WriteString(line) |
| 3263 | } |
| 3264 | digest := strings.TrimSpace(builder.String()) |
| 3265 | if len(digest) > 4000 { |
| 3266 | digest = truncateUTF8Bytes(digest, 4000) |
| 3267 | } |
| 3268 | return digest, sourceIDs, found |
| 3269 | } |
| 3270 | |
| 3271 | func nativeNetworkThreadPromotionMessageLine(message store.NetworkConversationMessage) string { |
| 3272 | preview := strings.TrimSpace(message.PreviewText) |