diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2025-11-30 20:27:30 -0800 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2025-11-30 20:27:30 -0800 |
| commit | 3cf1a74876f5576f05257996f2246db4c41343c6 (patch) | |
| tree | b4445b073fc830cae034d708b04ef0ed27dc8f26 | |
| parent | d3ea59508f3d0b96df3eb3b7e5882cb0aad3f3d5 (diff) | |
Fix panic when posting article to empty news category
| -rw-r--r-- | internal/mobius/threaded_news.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/mobius/threaded_news.go b/internal/mobius/threaded_news.go index f785bdf..eae2349 100644 --- a/internal/mobius/threaded_news.go +++ b/internal/mobius/threaded_news.go @@ -135,10 +135,18 @@ func (n *ThreadedNewsYAML) PostArticle(newsPath []string, parentArticleID uint32 } cats := n.getCatByPath(newsPath[:len(newsPath)-1]) + if cats == nil { + return fmt.Errorf("parent category path does not exist") + } catName := newsPath[len(newsPath)-1] cat := cats[catName] + // Initialize Articles map if nil (e.g., from old YAML files) + if cat.Articles == nil { + cat.Articles = make(map[uint32]*hotline.NewsArtData) + } + var keys []int for k := range cat.Articles { keys = append(keys, int(k)) |