model

package
v0.0.0-...-65a89f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB                 = 1024
	MsgSizeLimitBase   = 10 * KB
	MsgSizeLimitMargin = 5 * KB
	MsgSizeLimit       = MsgSizeLimitBase + MsgSizeLimitMargin // 15KB
	AvatarSizeLimit    = 150 * KB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Island

type Island struct {
	ID      string    // primary key
	Name    string    // 岛名
	Email   string    // Email
	Avatar  string    // 头像
	Link    string    // 小岛主页或岛主博客
	Note    string    // 对该小岛的备注或评价
	Hide    bool      // 小岛是否允许公开访问
	Message SimpleMsg // 最新一条消息
}

func NewIsland

func NewIsland(nl *Newsletter) Island

type Message

type Message struct {
	ID       string
	IslandID string
	Time     int64
	Body     string
}

func NewMessage

func NewMessage(islandID, body string) *Message

func (*Message) ToSimple

func (msg *Message) ToSimple() *SimpleMsg

type Newsletter

type Newsletter struct {
	Name     string       `json:"name"`
	Email    string       `json:"email"`
	Avatar   string       `json:"avatar"`
	Link     string       `json:"link"`
	Messages []*SimpleMsg `json:"messages"`
}

func (*Newsletter) Check

func (nl *Newsletter) Check() (err error)

Check 检查 newsletter 是否含有必要的项目。 注意,应检查经 Tirm() 处理后的 newsletter, 即应 "先trim后check".

func (*Newsletter) Trim

func (nl *Newsletter) Trim() *Newsletter

Trim 清除多余的空格,也清除 SimpleMsg.Body 为空的消息, 并且,如果 SimpleMsg.Time 比 time.Now() 晚超过 24 小时,这样的消息也应清除。

type SimpleMsg

type SimpleMsg struct {
	Time int64  `json:"time"`
	Body string `json:"body"`
}

func (*SimpleMsg) ToMessage

func (msg *SimpleMsg) ToMessage(islandID string) *Message

type Titles

type Titles struct {
	Title    string
	Subtitle string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL