Skip to content

Commit 56739ce

Browse files
committed
Merge branch 'release/v1.25.1'
2 parents 8d86b39 + 5240b1b commit 56739ce

21 files changed

+353
-326
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
Notable changes to Mailpit will be documented in this file.
44

5+
## [v1.25.1]
6+
7+
### Chore
8+
- Switch from unnecessary float64 to uint64 API values for App Information, message & attachment sizes
9+
- Extend latest version cache expiration from 5 to 15 minutes
10+
- Lighten outline-secondary buttons in dark mode
11+
- Add note to swagger docs about API date formats
12+
- Update Go dependencies
13+
- Update node dependencies
14+
15+
### Fix
16+
- Update bootstrap5-tags to fix text pasting in message release modal ([#498](https://github.com/axllent/mailpit/issues/498))
17+
18+
519
## [v1.25.0]
620

721
### Feature

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
golang.org/x/net v0.40.0
3131
golang.org/x/text v0.25.0
3232
golang.org/x/time v0.11.0
33-
modernc.org/sqlite v1.37.0
33+
modernc.org/sqlite v1.37.1
3434
)
3535

3636
require (
@@ -46,7 +46,7 @@ require (
4646
github.com/mattn/go-isatty v0.0.20 // indirect
4747
github.com/mattn/go-runewidth v0.0.16 // indirect
4848
github.com/ncruces/go-strftime v0.1.9 // indirect
49-
github.com/olekukonko/tablewriter v1.0.5 // indirect
49+
github.com/olekukonko/tablewriter v1.0.6 // indirect
5050
github.com/pkg/errors v0.9.1 // indirect
5151
github.com/reiver/go-oi v1.0.0 // indirect
5252
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
@@ -58,7 +58,7 @@ require (
5858
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
5959
golang.org/x/image v0.27.0 // indirect
6060
golang.org/x/sys v0.33.0 // indirect
61-
modernc.org/libc v1.65.7 // indirect
61+
modernc.org/libc v1.65.8 // indirect
6262
modernc.org/mathutil v1.7.1 // indirect
6363
modernc.org/memory v1.11.0 // indirect
6464
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ modernc.org/fileutil v1.3.1 h1:8vq5fe7jdtEvoCf3Zf9Nm0Q05sH6kGx0Op2CPx1wTC8=
202202
modernc.org/fileutil v1.3.1/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
203203
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
204204
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
205-
modernc.org/libc v1.65.7 h1:Ia9Z4yzZtWNtUIuiPuQ7Qf7kxYrxP1/jeHZzG8bFu00=
206-
modernc.org/libc v1.65.7/go.mod h1:011EQibzzio/VX3ygj1qGFt5kMjP0lHb0qCW5/D/pQU=
205+
modernc.org/libc v1.65.8 h1:7PXRJai0TXZ8uNA3srsmYzmTyrLoHImV5QxHeni108Q=
206+
modernc.org/libc v1.65.8/go.mod h1:011EQibzzio/VX3ygj1qGFt5kMjP0lHb0qCW5/D/pQU=
207207
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
208208
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
209209
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
@@ -212,8 +212,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
212212
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
213213
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
214214
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
215-
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
216-
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
215+
modernc.org/sqlite v1.37.1 h1:EgHJK/FPoqC+q2YBXg7fUmES37pCHFc97sI7zSayBEs=
216+
modernc.org/sqlite v1.37.1/go.mod h1:XwdRtsE1MpiBcL54+MbKcaDvcuej+IYSMfLN6gSKV8g=
217217
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
218218
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
219219
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=

internal/pop3/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func Run() {
8080

8181
type message struct {
8282
ID string
83-
Size float64
83+
Size uint64
8484
}
8585

8686
func handleClient(conn net.Conn) {
@@ -211,13 +211,13 @@ func handleClient(conn net.Conn) {
211211
func handleTransactionCommand(conn net.Conn, cmd string, args []string, messages []message, toDelete *[]string) {
212212
switch cmd {
213213
case "STAT":
214-
totalSize := float64(0)
214+
totalSize := uint64(0)
215215
for _, m := range messages {
216216
totalSize += m.Size
217217
}
218218
sendResponse(conn, fmt.Sprintf("+OK %d %d", len(messages), int64(totalSize)))
219219
case "LIST":
220-
totalSize := float64(0)
220+
totalSize := uint64(0)
221221
for _, m := range messages {
222222
totalSize += m.Size
223223
}

internal/stats/stats.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ var (
2020

2121
mu sync.RWMutex
2222

23-
smtpAccepted float64
24-
smtpAcceptedSize float64
25-
smtpRejected float64
26-
smtpIgnored float64
23+
smtpAccepted uint64
24+
smtpAcceptedSize uint64
25+
smtpRejected uint64
26+
smtpIgnored uint64
2727
)
2828

2929
// AppInformation struct
@@ -36,29 +36,29 @@ type AppInformation struct {
3636
// Database path
3737
Database string
3838
// Database size in bytes
39-
DatabaseSize float64
39+
DatabaseSize uint64
4040
// Total number of messages in the database
41-
Messages float64
41+
Messages uint64
4242
// Total number of messages in the database
43-
Unread float64
43+
Unread uint64
4444
// Tags and message totals per tag
4545
Tags map[string]int64
4646
// Runtime statistics
4747
RuntimeStats struct {
4848
// Mailpit server uptime in seconds
49-
Uptime float64
49+
Uptime uint64
5050
// Current memory usage in bytes
5151
Memory uint64
5252
// Database runtime messages deleted
53-
MessagesDeleted float64
53+
MessagesDeleted uint64
5454
// Accepted runtime SMTP messages
55-
SMTPAccepted float64
55+
SMTPAccepted uint64
5656
// Total runtime accepted messages size in bytes
57-
SMTPAcceptedSize float64
57+
SMTPAcceptedSize uint64
5858
// Rejected runtime SMTP messages
59-
SMTPRejected float64
59+
SMTPRejected uint64
6060
// Ignored runtime SMTP messages (when using --ignore-duplicate-ids)
61-
SMTPIgnored float64
61+
SMTPIgnored uint64
6262
}
6363
}
6464

@@ -71,7 +71,7 @@ func Load() AppInformation {
7171
runtime.ReadMemStats(&m)
7272

7373
info.RuntimeStats.Memory = m.Sys - m.HeapReleased
74-
info.RuntimeStats.Uptime = time.Since(startedAt).Seconds()
74+
info.RuntimeStats.Uptime = uint64(time.Since(startedAt).Seconds())
7575
info.RuntimeStats.MessagesDeleted = storage.StatsDeleted
7676
info.RuntimeStats.SMTPAccepted = smtpAccepted
7777
info.RuntimeStats.SMTPAcceptedSize = smtpAcceptedSize
@@ -88,7 +88,7 @@ func Load() AppInformation {
8888

8989
// clear latest version cache after 5 minutes
9090
go func() {
91-
time.Sleep(5 * time.Minute)
91+
time.Sleep(15 * time.Minute)
9292
latestVersionCache = ""
9393
}()
9494
}
@@ -112,7 +112,7 @@ func Track() {
112112
func LogSMTPAccepted(size int) {
113113
mu.Lock()
114114
smtpAccepted = smtpAccepted + 1
115-
smtpAcceptedSize = smtpAcceptedSize + float64(size)
115+
smtpAcceptedSize = smtpAcceptedSize + uint64(size)
116116
mu.Unlock()
117117
}
118118

internal/storage/cron.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func dbCron() {
3232
if total == 0 {
3333
deletedPercent = 100
3434
} else {
35-
deletedPercent = deletedSize * 100 / total
35+
deletedPercent = float64(deletedSize * 100 / total)
3636
}
3737
// only vacuum the DB if at least 1% of mail storage size has been deleted
3838
if deletedPercent >= 1 {
@@ -56,13 +56,13 @@ func pruneMessages() {
5656
start := time.Now()
5757

5858
ids := []string{}
59-
var prunedSize int64
60-
var size float64
59+
var prunedSize uint64
60+
var size uint64
6161

6262
// prune using `--max` if set
6363
if config.MaxMessages > 0 {
6464
total := CountTotal()
65-
if total > float64(config.MaxAgeInHours) {
65+
if total > uint64(config.MaxAgeInHours) {
6666
offset := config.MaxMessages
6767
if config.DemoMode {
6868
offset = 500
@@ -81,7 +81,7 @@ func pruneMessages() {
8181
return
8282
}
8383
ids = append(ids, id)
84-
prunedSize = prunedSize + int64(size)
84+
prunedSize = prunedSize + size
8585

8686
}); err != nil {
8787
logger.Log().Errorf("[db] %s", err.Error())
@@ -110,7 +110,7 @@ func pruneMessages() {
110110

111111
if !tools.InArray(id, ids) {
112112
ids = append(ids, id)
113-
prunedSize = prunedSize + int64(size)
113+
prunedSize = prunedSize + size
114114
}
115115

116116
}); err != nil {

internal/storage/database.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ func StatsGet() MailboxStats {
210210
}
211211

212212
// CountTotal returns the number of emails in the database
213-
func CountTotal() float64 {
214-
var total float64
213+
func CountTotal() uint64 {
214+
var total uint64
215215

216216
_ = sqlf.From(tenant("mailbox")).
217217
Select("COUNT(*)").To(&total).
@@ -221,8 +221,8 @@ func CountTotal() float64 {
221221
}
222222

223223
// CountUnread returns the number of emails in the database that are unread.
224-
func CountUnread() float64 {
225-
var total float64
224+
func CountUnread() uint64 {
225+
var total uint64
226226

227227
_ = sqlf.From(tenant("mailbox")).
228228
Select("COUNT(*)").To(&total).
@@ -233,8 +233,8 @@ func CountUnread() float64 {
233233
}
234234

235235
// CountRead returns the number of emails in the database that are read.
236-
func CountRead() float64 {
237-
var total float64
236+
func CountRead() uint64 {
237+
var total uint64
238238

239239
_ = sqlf.From(tenant("mailbox")).
240240
Select("COUNT(*)").To(&total).
@@ -245,17 +245,17 @@ func CountRead() float64 {
245245
}
246246

247247
// DbSize returns the size of the SQLite database.
248-
func DbSize() float64 {
249-
var total sql.NullFloat64
248+
func DbSize() uint64 {
249+
var total sql.NullInt64
250250

251251
err := db.QueryRow("SELECT page_count * page_size AS size FROM pragma_page_count(), pragma_page_size()").Scan(&total)
252252

253253
if err != nil {
254254
logger.Log().Errorf("[db] %s", err.Error())
255-
return total.Float64
255+
return uint64(total.Int64)
256256
}
257257

258-
return total.Float64
258+
return uint64(total.Int64)
259259
}
260260

261261
// MessageIDExists checks whether a Message-ID exists in the DB

internal/storage/messages.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func Store(body *[]byte) (string, error) {
8585
defer tx.Rollback()
8686

8787
subject := env.GetHeader("Subject")
88-
size := float64(len(*body))
88+
size := uint64(len(*body))
8989
inline := len(env.Inlines)
9090
attachments := len(env.Attachments)
9191
snippet := tools.CreateSnippet(env.Text, env.HTML)
@@ -201,12 +201,12 @@ func List(start int, beforeTS int64, limit int) ([]MessageSummary, error) {
201201
}
202202

203203
if err := q.QueryAndClose(context.TODO(), db, func(row *sql.Rows) {
204-
var created float64
204+
var created uint64
205205
var id string
206206
var messageID string
207207
var subject string
208208
var metadata string
209-
var size float64
209+
var size uint64
210210
var attachments int
211211
var read int
212212
var snippet string
@@ -294,7 +294,7 @@ func GetMessage(id string) (*Message, error) {
294294
Where(`ID = ?`, id)
295295

296296
if err := q.QueryAndClose(context.TODO(), db, func(row *sql.Rows) {
297-
var created float64
297+
var created uint64
298298

299299
if err := row.Scan(&created); err != nil {
300300
logger.Log().Errorf("[db] %s", err.Error())
@@ -321,7 +321,7 @@ func GetMessage(id string) (*Message, error) {
321321
ReturnPath: returnPath,
322322
Subject: env.GetHeader("Subject"),
323323
Tags: getMessageTags(id),
324-
Size: float64(len(raw)),
324+
Size: uint64(len(raw)),
325325
Text: env.Text,
326326
}
327327

@@ -462,7 +462,7 @@ func AttachmentSummary(a *enmime.Part) Attachment {
462462
}
463463
o.ContentType = a.ContentType
464464
o.ContentID = a.ContentID
465-
o.Size = float64(len(a.Content))
465+
o.Size = uint64(len(a.Content))
466466

467467
return o
468468
}
@@ -617,11 +617,11 @@ func DeleteMessages(ids []string) error {
617617
defer rows.Close()
618618

619619
toDelete := []string{}
620-
var totalSize float64
620+
var totalSize uint64
621621

622622
for rows.Next() {
623623
var id string
624-
var size float64
624+
var size uint64
625625
if err := rows.Scan(&id, &size); err != nil {
626626
return err
627627
}
@@ -663,7 +663,7 @@ func DeleteMessages(ids []string) error {
663663
}
664664

665665
dbLastAction = time.Now()
666-
addDeletedSize(int64(totalSize))
666+
addDeletedSize(totalSize)
667667

668668
logMessagesDeleted(len(toDelete))
669669

0 commit comments

Comments
 (0)