Documentation ¶
Index ¶
- Variables
- type Database
- func (d *Database) ConfirmUser(userID string, confirmCode int) (confirmed bool, err error)
- func (d *Database) CreateUser(user *model.User) (userid string, confirm int, err error)
- func (d *Database) DeleteThread(threadID string) (err error)
- func (d *Database) EditPost(id string, body string) (post model.Post, err error)
- func (d *Database) EditUser(user *model.User) (err error)
- func (d *Database) GetMessage(messageID string) (model.Message, error)
- func (d *Database) GetMessagePosts(messageID string) ([]model.MessagePost, error)
- func (d *Database) GetMessages(num int, userid string) ([]model.Message, error)
- func (d *Database) GetPost(postID string) (post model.Post, err error)
- func (d *Database) GetPosts(threadId string) ([]model.Post, error)
- func (d *Database) GetThread(threadID string) (model.Thread, error)
- func (d *Database) GetThreads(num int, since string) ([]model.Thread, error)
- func (d *Database) GetUser(username string) (user model.User, err error)
- func (d *Database) GetUserInfo(userID string) (userInfo model.UserInfo, err error)
- func (d *Database) GetUsers(search string) ([]model.User, error)
- func (d *Database) HandlePasswordMigration(user *model.User, credentials *model.Credentials) error
- func (d *Database) InitDb(environment string, configPath string) error
- func (d *Database) PostMessage(newMessage *model.NewMessage) (message model.NewMessage, err error)
- func (d *Database) PostMessagePost(message *model.MessagePost) (newMessage model.MessagePost, err error)
- func (d *Database) PostPost(post *model.Post) (newPost model.Post, err error)
- func (d *Database) PostThread(newThread *model.NewThread) (thread model.NewThread, err error)
- type IDatabase
- type MockDatabase
Constants ¶
This section is empty.
Variables ¶
var DB *sql.DB
var ErrEditPost = errors.New("Posts can only be edited for 10 minutes")
ErrEditPost occurs when a user tries to edit a post after the designated time
var ErrNoThread = errors.New("Couldn't find that thread")
ErrNoThread occurs when a thread doesn't exist
var ErrWrongPassword = errors.New("Wrong password")
ErrWrongPassword when a user enters a password that doesn't match
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { }
func (*Database) ConfirmUser ¶
ConfirmUser sets a user to active in the database
func (*Database) CreateUser ¶
CreateUser creates a new user.
func (*Database) DeleteThread ¶
DeleteThread will do a soft delete on a thread and all of its corresponding posts.
func (*Database) GetMessage ¶
GetMessage will get a message with the given ID.
func (*Database) GetMessagePosts ¶
func (d *Database) GetMessagePosts(messageID string) ([]model.MessagePost, error)
GetMessagePosts will return all posts under a given thread.
func (*Database) GetMessages ¶
GetMessages retrieves a given number of messages.
func (*Database) GetThreads ¶
GetThreads retrieves a given number of threads.
func (*Database) GetUserInfo ¶
GetUserInfo retrieves metadata about a user.
func (*Database) GetUsers ¶
GetUsers will return a list of users whose username matches a search string.
func (*Database) HandlePasswordMigration ¶
HandlePasswordMigration will check a user's password against their hashed MD5 password from the legacy site. If it's a match, it will encrypt their password with bcrypt and delete the hashed password.
func (*Database) PostMessage ¶
func (d *Database) PostMessage(newMessage *model.NewMessage) (message model.NewMessage, err error)
PostMessage will create a new message "thread".
func (*Database) PostMessagePost ¶
func (d *Database) PostMessagePost(message *model.MessagePost) (newMessage model.MessagePost, err error)
PostMessagePost will create a new message_post in an existing message.
type IDatabase ¶
type IDatabase interface { InitDb(s string, e string) error EditUser(u *model.User) error CreateUser(u *model.User) (string, int, error) ConfirmUser(s string, i int) (bool, error) GetUser(s string) (model.User, error) GetUsers(s string) ([]model.User, error) GetThread(s string) (model.Thread, error) GetMessage(s string) (model.Message, error) GetMessages(i int, u string) ([]model.Message, error) GetMessagePosts(s string) ([]model.MessagePost, error) GetPost(s string) (model.Post, error) GetPosts(s string) ([]model.Post, error) GetThreads(i int, since string) ([]model.Thread, error) GetUserInfo(userID string) (model.UserInfo, error) HandlePasswordMigration(u *model.User, c *model.Credentials) error PostThread(t *model.NewThread) (model.NewThread, error) PostPost(p *model.Post) (model.Post, error) PostMessage(t *model.NewMessage) (model.NewMessage, error) PostMessagePost(p *model.MessagePost) (model.MessagePost, error) DeleteThread(s string) error EditPost(i string, b string) (model.Post, error) }
type MockDatabase ¶
type MockDatabase struct { }
func (*MockDatabase) GetPosts ¶
func (m *MockDatabase) GetPosts(threadId string) ([]model.Post, error)
func (*MockDatabase) GetThread ¶
func (m *MockDatabase) GetThread(threadId string) (model.Thread, error)