models

package
v0.0.0-...-29d43fa Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GreentextRegex = regexp.MustCompile(">.+")
View Source
var PostCitationRegex = regexp.MustCompile(">> ([0-9]+)")

Functions

This section is empty.

Types

type Ban

type Ban struct {
	IP        net.IP
	Reason    string
	StartDate time.Time
	EndDate   time.Time
}

type BanModel

type BanModel struct {
	DbConn *goqu.Database
}

func (*BanModel) BanUser

func (bm *BanModel) BanUser(ip net.IP, endDate time.Time, reason string) error

func (*BanModel) GetBan

func (bm *BanModel) GetBan(ip net.IP) (Ban, error)

func (*BanModel) GetBans

func (bm *BanModel) GetBans(pageNumber, itemsPerPage uint) ([]Ban, error)

func (*BanModel) IsBanned

func (bm *BanModel) IsBanned(r *http.Request) (bool, Ban, error)

func (*BanModel) UnbanUser

func (bm *BanModel) UnbanUser(ip net.IP) error

type Board

type Board struct {
	ID         string
	FullName   string
	LastPostID uint
	BumpLimit  uint
}

type BoardModel

type BoardModel struct {
	DbConn      *goqu.Database
	ThreadModel *ThreadModel
}

func (*BoardModel) Delete

func (m *BoardModel) Delete(id string) error

func (*BoardModel) GetBoards

func (m *BoardModel) GetBoards() ([]Board, error)

func (*BoardModel) Insert

func (m *BoardModel) Insert(id string, name string, bumpLimit uint) error

func (*BoardModel) Update

func (m *BoardModel) Update(board Board) error

type Citation

type Citation struct {
	BoardID string
	PostID  uint
	Cites   uint
}

func GetCitations

func GetCitations(boardId string, postId uint, content string) []Citation

type CitationModel

type CitationModel struct {
	DbConn *goqu.Database
}

func (*CitationModel) GetCitationsForPosts

func (cm *CitationModel) GetCitationsForPosts(boardId string, posts ...*Post) error

type FileInfo

type FileInfo struct {
	ID          string
	Name        string
	ContentType string
}

func (FileInfo) ContainsImage

func (fi FileInfo) ContainsImage() bool

type FileInfoModel

type FileInfoModel struct {
	DbConn    *goqu.Database
	FileStore filestorage.FileStore
}

func (*FileInfoModel) Delete

func (fiModel *FileInfoModel) Delete(fileId string) error

func (*FileInfoModel) DeleteOrphanedFiles

func (fiModel *FileInfoModel) DeleteOrphanedFiles() error

func (*FileInfoModel) GetFilesForPosts

func (fiModel *FileInfoModel) GetFilesForPosts(boardId string, posts ...*Post) error

func (*FileInfoModel) GetLatestFiles

func (fiModel *FileInfoModel) GetLatestFiles() ([]map[string]interface{}, error)

func (*FileInfoModel) InsertFile

func (fiModel *FileInfoModel) InsertFile(fileName string, file []byte) (FileInfo, error)

type Post

type Post struct {
	ID        uint
	BoardID   string
	CreatedAt time.Time
	Content   string
	Files     []FileInfo
	Citations []Citation
	PosterIP  net.IP
}

func (Post) FileCount

func (p Post) FileCount() int

func (Post) FormatCreationDate

func (p Post) FormatCreationDate() template.HTML

func (Post) FormatedContent

func (p Post) FormatedContent() template.HTML

type Reply

type Reply struct {
	Post
	ThreadID uint
}

func (Reply) GetType

func (t Reply) GetType() string

type ReplyModel

type ReplyModel struct {
	DbConn        *goqu.Database
	FileInfoModel *FileInfoModel
	CitationModel *CitationModel
}

func (*ReplyModel) Delete

func (m *ReplyModel) Delete(boardId string, id uint) (uint, error)

func (*ReplyModel) Get

func (m *ReplyModel) Get(boardId string, replyId uint) (*Reply, error)

func (*ReplyModel) GetLatestReplies

func (m *ReplyModel) GetLatestReplies(boardId string, limit int, threads ...*Thread) error

func (*ReplyModel) GetLatestRepliesFromEveryThread

func (m *ReplyModel) GetLatestRepliesFromEveryThread() ([]*Reply, error)

func (*ReplyModel) GetRepliesToThreads

func (m *ReplyModel) GetRepliesToThreads(boardId string, threads ...*Thread) error

func (*ReplyModel) Insert

func (m *ReplyModel) Insert(boardId string, threadId uint, content string, files []FileInfo, posterIp string) (uint, error)

type Thread

type Thread struct {
	Post
	Title   string
	Replies []*Reply
}

func (Thread) GetType

func (t Thread) GetType() string

type ThreadModel

type ThreadModel struct {
	DbConn        *goqu.Database
	FileInfoModel *FileInfoModel
	CitationModel *CitationModel
	ReplyModel    *ReplyModel
}

func (*ThreadModel) Delete

func (m *ThreadModel) Delete(boardId string, threadIds ...uint) error

func (*ThreadModel) Get

func (m *ThreadModel) Get(boardId string, threadId uint) (*Thread, error)

func (*ThreadModel) GetBanCount

func (m *ThreadModel) GetBanCount() (uint, error)

func (*ThreadModel) GetLatest

func (m *ThreadModel) GetLatest(boardId string, pageNumber, itemsPerPage uint) ([]*Thread, error)

func (*ThreadModel) GetLatestFromEveryBoard

func (m *ThreadModel) GetLatestFromEveryBoard() ([]*Thread, error)

func (*ThreadModel) GetThreadCount

func (m *ThreadModel) GetThreadCount(boardId string) (uint, error)

func (*ThreadModel) Insert

func (m *ThreadModel) Insert(boardId, title, content string, files []FileInfo, posterIp string) (uint, error)

type User

type User struct {
	Username    string
	DisplayName string
	Permission  UserPermission
}

type UserModel

type UserModel struct {
	DbConn *goqu.Database
}

func (*UserModel) ChangeUserPassword

func (um *UserModel) ChangeUserPassword(username, password string) error

func (*UserModel) Delete

func (um *UserModel) Delete(username string) error

func (*UserModel) GetUser

func (um *UserModel) GetUser(username string) (User, error)

func (*UserModel) GetUsers

func (um *UserModel) GetUsers() ([]User, error)

func (*UserModel) Login

func (um *UserModel) Login(username, password string) (User, error)

func (*UserModel) RegisterUser

func (um *UserModel) RegisterUser(username string, displayName string, permission UserPermission) (string, error)

func (*UserModel) ResetUserPassword

func (um *UserModel) ResetUserPassword(username string) (string, error)

func (*UserModel) SetPassword

func (um *UserModel) SetPassword(username, newPassword string) error

func (*UserModel) Update

func (um *UserModel) Update(user User) error

type UserPermission

type UserPermission int
const (
	Admin UserPermission = iota
	Moderator
)

type WrongPasswordError

type WrongPasswordError struct{}

func (WrongPasswordError) Error

func (e WrongPasswordError) Error() string

Jump to

Keyboard shortcuts

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