Documentation
¶
Index ¶
- Constants
- func CheckExists(filepath string) bool
- func Migration20240116_PwhashChange(filepath string) (finalErr error)
- func Migration20240720_ThreadPrivateChange(filepath string) (finalErr error)
- type DB
- func (d DB) AddAdmin(userid int) error
- func (d DB) AddModerationLog(actingid, recipientid, action int) error
- func (d DB) AddPost(content string, threadid, authorid int) (postID int)
- func (d DB) AddRegistration(userid int, verificationLink string) error
- func (d DB) CheckThreadExists(threadid int) (bool, error)
- func (d DB) CheckUserExists(userid int) (bool, error)
- func (d DB) CheckUsernameExists(username string) (bool, error)
- func (d DB) CreateThread(title, content string, authorid, topicid int, isPrivate bool) (int, error)
- func (d DB) CreateTopic(title, description string)
- func (d DB) CreateUser(name, hash string) (int, error)
- func (d DB) DeletePost(postid int) error
- func (d DB) DeleteThread()
- func (d DB) DeleteTopic(topicid int)
- func (d DB) DemoteAdmin(userid int) error
- func (d DB) EditPost(content string, postid int)
- func (d DB) Exec(stmt string, args ...interface{}) (sql.Result, error)
- func (d DB) FinalizeProposedAction(proposalid, adminid int, decision bool) (finalErr error)
- func (d DB) GetAdmins() []User
- func (d DB) GetModerationLogs() []ModerationEntry
- func (d DB) GetPasswordHash(username string) (string, int, error)
- func (d DB) GetPost(postid int) (Post, error)
- func (d DB) GetProposedActions() []ModProposal
- func (d DB) GetSystemUserid() int
- func (d DB) GetThread(threadid int) ([]Post, error)
- func (d DB) GetUserID(name string) (int, error)
- func (d DB) GetUsername(uid int) (string, error)
- func (d DB) GetUsers(includeAdmin bool) []User
- func (d DB) IsThreadPrivate(threadid int) (bool, error)
- func (d DB) IsUserAdmin(userid int) (bool, error)
- func (d DB) ListThreads(sortByPost bool, includePrivate bool) []Thread
- func (d DB) MoveThread()
- func (d DB) ProposeModerationAction(proposerid, recipientid, action int) (finalErr error)
- func (d DB) QuorumActivated() bool
- func (d DB) RemoveUser(userid int) (finalErr error)
- func (d DB) ResetPassword(userid int) (string, error)
- func (d DB) UpdateTopicDescription(topicid int, newdesc string)
- func (d DB) UpdateTopicName(topicid int, newname string)
- func (d DB) UpdateUserName(userid int, newname string)
- func (d DB) UpdateUserPasswordHash(userid int, newhash string)
- type ModProposal
- type ModerationEntry
- type Post
- type Thread
- type User
Constants ¶
const DELETED_USER_NAME = "deleted user"
const SYSTEM_USER_NAME = "CERCA_CMD"
Variables ¶
This section is empty.
Functions ¶
func CheckExists ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (DB) AddModerationLog ¶
func (DB) CreateThread ¶
func (DB) CreateTopic ¶
func (DB) DeletePost ¶
func (DB) DeleteThread ¶
func (d DB) DeleteThread()
func (DB) DeleteTopic ¶
func (DB) DemoteAdmin ¶
func (DB) Exec ¶
goal for 2021-12-28
* in browser: reply on a thread * in browser: create a new thread
func (DB) FinalizeProposedAction ¶
finalize a proposal by either confirming or vetoing it, logging the requisite information and then finally executing the proposed action itself
func (DB) GetModerationLogs ¶
func (d DB) GetModerationLogs() []ModerationEntry
func (DB) GetProposedActions ¶
func (d DB) GetProposedActions() []ModProposal
func (DB) GetSystemUserid ¶
func (DB) ListThreads ¶
get a list of threads NOTE: this query is setting thread.Author not by thread creator, but latest poster. if this becomes a problem, revert its use and employ Thread.PostID to perform another query for each thread to get the post author name (wrt server.go:GenerateRSS)
func (DB) MoveThread ¶
func (d DB) MoveThread()
func (DB) ProposeModerationAction ¶
func (DB) QuorumActivated ¶
func (DB) RemoveUser ¶
there are a bunch of places that reference a user's id, so i don't want to break all of those
i also want to avoid big invisible holes in a conversation's history
remove user performs the following operation: 1. checks to see if the DELETED USER exists; otherwise create it and remember its id
2. if it exists, we swap out the userid for the DELETED_USER in tables: - table threads authorid - table posts authorid - table moderation_log actingid or recipientid
the entry in registrations correlating to userid is removed if allowing deletion of post contents as well when removing account, userid should be used to get all posts from table posts and change the contents to say _deleted_
func (DB) UpdateTopicDescription ¶
func (DB) UpdateTopicName ¶
func (DB) UpdateUserName ¶
func (DB) UpdateUserPasswordHash ¶
type ModProposal ¶
type ModerationEntry ¶
type Post ¶
type Post struct {
ID int
ThreadTitle string
ThreadID int
Content string // markdown
Author string
AuthorID int
Publish time.Time
LastEdit sql.NullTime // TODO: handle json marshalling with custom type
}
c.f. https://medium.com/aubergine-solutions/how-i-handled-null-possible-values-from-database-rows-in-golang-521fb0ee267 type NullTime sql.NullTime