Skip to content

Commit

Permalink
update parsemail, update carrot, gormpher
Browse files Browse the repository at this point in the history
  • Loading branch information
szluyu99 committed Apr 17, 2023
1 parent efddbce commit 9a47e40
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 20 deletions.
3 changes: 2 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"strings"
"time"

"github.com/DusanKasan/parsemail"
"github.com/emersion/go-smtp"
"github.com/restsend/carrot"
"github.com/restsend/parsemail"
)

// A Session is returned after successful login.
Expand All @@ -28,6 +28,7 @@ type Session struct {
func (s *Session) ID() string {
return colorize(ColorBlue, s.c.Conn().RemoteAddr().String())
}

func (s *Session) Current() *Mail {
if s._mail == nil {
uuid := carrot.GenUniqueKey(s.b.db.Model(&Mail{}), "id", carrot.GetIntValue(s.b.db, key_MAIL_UUID_SIZE, 8))
Expand Down
1 change: 1 addition & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Here are the email package modules we'll need.
from email.message import EmailMessage
from email.utils import make_msgid

# Create the container email message.
msg = EmailMessage()
msg['Subject'] = 'Hello SMTP Preview' + time.ctime()
Expand Down
16 changes: 11 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ module github.com/restsend/smtppreview

go 1.19

require github.com/restsend/carrot v0.0.0-20230320040726-7216e2458fef
require (
github.com/restsend/carrot v0.0.0-20230414101657-69aa668a664f
github.com/restsend/gormpher v0.0.0-20230417103118-5a9ffe485c20
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
)

// replace github.com/restsend/gormpher => ../../gormpher
// replace github.com/restsend/parsemail => ../../restsend/parsemail

require (
github.com/DusanKasan/parsemail v1.2.0
github.com/bytedance/sonic v1.8.5 // indirect
github.com/bytedance/sonic v1.8.6 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/emersion/go-smtp v0.16.0
github.com/flosch/pongo2/v6 v6.0.0 // indirect
github.com/gin-contrib/sessions v0.0.5 // indirect
github.com/gin-contrib/sessions v0.0.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.0
github.com/go-playground/locales v0.14.1 // indirect
Expand All @@ -33,8 +39,8 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
Expand Down
19 changes: 10 additions & 9 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (

_ "embed"

"github.com/DusanKasan/parsemail"
"github.com/gin-gonic/gin"
"github.com/restsend/carrot"
"github.com/restsend/gormpher"
"github.com/restsend/parsemail"
"gorm.io/gorm"
)

Expand All @@ -36,17 +37,17 @@ func RegisterHandlers(r *gin.RouterGroup, be *Backend) {
routes.POST("/config/edit", handleEditConfig)
routes.GET("/render/:id", handleRender)

carrot.RegisterObject(routes, &carrot.WebObject{
Model: Mail{},
Name: "mail",
Editables: []string{"Opened", "OpenAt"},
Filters: []string{"Opened", "OpenAt", "Score"},
Orders: []string{"CreatedAt", "OpenAt", "Score"},
Searchs: []string{"Subject", "From", "To"},
gormpher.RegisterObject(routes, &gormpher.WebObject{
Model: Mail{},
Name: "mail",
Editables: []string{"Opened", "OpenAt"},
Filterables: []string{"Opened", "OpenAt", "Score"},
Orderables: []string{"CreatedAt", "OpenAt", "Score"},
Searchables: []string{"Subject", "From", "To"},
GetDB: func(ctx *gin.Context, isCreate bool) *gorm.DB {
return be.db
},
AllowMethods: carrot.GET | carrot.DELETE | carrot.EDIT | carrot.QUERY,
AllowMethods: gormpher.GET | gormpher.DELETE | gormpher.EDIT | gormpher.QUERY,
})
}

Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var assets embed.FS
var indexHTML string

func main() {

log.Default().SetFlags(logFlags)

var smtpServerAddr string
Expand Down
2 changes: 1 addition & 1 deletion ui/dist/assets/index.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ async function onPrev(msgid) {
</div>
</div>
<div class="border-t border-b border-gray-200 bg-gray-50 px-6 py-2 text-sm font-medium text-gray-500">
Sorted
by date</div>
Sorted by date</div>
</div>
<nav aria-label="Message list" class="min-h-0 flex-1 overflow-y-auto">
<ul role="list" class="divide-y divide-gray-200 border-b border-gray-200">
Expand Down
2 changes: 1 addition & 1 deletion ui/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function getSummary() {
}

export async function listMails(pos, keyword, limit = 20) {
let req = await fetch(`/api/mail/query`, {
let req = await fetch(`/api/mail`, {
method: 'POST',
body: JSON.stringify({
pos, keyword, limit,
Expand Down

0 comments on commit 9a47e40

Please sign in to comment.