chore(repo): reinitialize repository

This commit is contained in:
2026-03-18 11:29:54 +08:00
commit 24871e213a
288 changed files with 44369 additions and 0 deletions
@@ -0,0 +1,63 @@
package dashboard
import (
"strings"
"inbox/internal/domain/message"
"inbox/internal/domain/topic"
)
func previewText(value string) string {
value = strings.TrimSpace(value)
if value == "" {
return ""
}
lines := strings.Split(value, "\n")
if len(lines) == 0 {
return value
}
return strings.TrimSpace(lines[0])
}
func splitRecipients(value string) []string {
parts := strings.Split(value, ",")
out := make([]string, 0, len(parts))
seen := make(map[string]struct{}, len(parts))
for _, part := range parts {
part = strings.TrimSpace(part)
if part == "" {
continue
}
if _, ok := seen[part]; ok {
continue
}
seen[part] = struct{}{}
out = append(out, part)
}
return out
}
func messageTargetsRole(expr, roleName string) bool {
for _, item := range splitRecipients(expr) {
if item == roleName {
return true
}
}
return false
}
func dashboardMessageItemFor(item message.Record, record topic.Record) dashboardMessageItem {
out := dashboardMessageItem{
MessageID: item.ID,
From: item.FromRoleName,
To: item.ToExpr,
Type: string(item.Type),
Topic: record.Slug,
Stage: item.Stage,
BodyMarkdown: item.BodyMarkdown,
}
if item.ReplyToMessageID != "" {
out.ReplyTo = item.ReplyToMessageID
}
return out
}