~dricottone/digestion

ref: db7d0c4d6769d65070e6b68056cd035e4e31d339 digestion/message/part.go -rw-r--r-- 820 bytes
db7d0c4dDominic Ricottone Adding parcels 2 years ago
                                                                                
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 message

import (
	"git.dominic-ricottone.com/~dricottone/digestion/decoder"
	"git.dominic-ricottone.com/~dricottone/digestion/renderer"
)

type MessagePart struct {
	Header             *MessagePartHeader
	Content            []string
}

func NewPart() *MessagePart {
	return &MessagePart{NewPartHeader(), []string{""}}
}

func (m *MessagePart) evaluate_type() int {
	switch renderer.DetermineFormatting(m.Header.ContentType) {
	case renderer.FormattedTextPlain:
		return 0
	case renderer.FormattedTextHTML:
		return 20
	default:
		return 30
	}
}

func (m *MessagePart) evaluate_encoding() int {
	switch decoder.DetermineEncoding(m.Header.ContentEncoding) {
	case decoder.EncodedUTF8:
		return 0
	case decoder.EncodedBase64:
		return 1
	case decoder.EncodedQuotedPrintable:
		return 1
	default:
		return 10
	}
}