aboutsummaryrefslogtreecommitdiff
blob: 7d046e626b6cf9700d09b67c1d29b84be5f3e2c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package list

import (
	"archives/pkg/config"
	"archives/pkg/models"
	"net/http"
)

func Browse(w http.ResponseWriter, r *http.Request) {

	// Count number of messages in the current mailing lists
	var currentMailingLists []models.MailingList
	for _, listName := range config.CurrentMailingLists() {
		messageCount, _ := countMessages(listName)
		currentMailingLists = append(currentMailingLists, models.MailingList{
			Name:         listName,
			MessageCount: messageCount,
		})
	}

	// Count number of messages in the frozen archives
	var frozenArchives []models.MailingList
	for _, listName := range config.FrozenArchives() {
		messageCount, _ := countMessages(listName)
		frozenArchives = append(frozenArchives, models.MailingList{
			Name:         listName,
			MessageCount: messageCount,
		})
	}

	browseData := struct {
		CurrentMailingLists []models.MailingList
		FrozenArchives      []models.MailingList
	}{
		CurrentMailingLists: currentMailingLists,
		FrozenArchives:      frozenArchives,
	}

	renderBrowseTemplate(w, browseData)
}