Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalFamily ¶
MarshalFamily converts a family struct to a byte slice
func MarshalGroup ¶
MarshalGroup converts a group struct to a byte slice
func MarshalUser ¶
MarshalUser takes a pointer to a Member struct and converts it into a slice of bytes for database storing It returns a non-nil error if there is an error, naturally
Types ¶
type Family ¶
type Family struct { FamilyName string `json:"name" html:"name"` FamilyID []byte `json:"id" html:"id"` Groups []string `json:"groups" html:"groups"` Members []string `json:"members" html:"members"` Elders []string `json:"elders" html:"elders"` //they get special priveleges Lists map[string]string `json:"lists" html:"lists"` // contains filtered or unexported fields }
Family will be like a user manager for a group of related people Doesn't have to be an actual family, just a group getting presents for each other I also may change family to a tree structure at some point. I know, womp womp
func NewFamily ¶
NewFamily does what it says on the tin Need a way to make this work with the database
func UnmarshalFamily ¶
UnmarshalFamily reforms a family from binary
func (*Family) AddElder ¶
AddElder takes a family member and promotes them to elder. Note that the user MUST already be a member of the family
func (*Family) AddMember ¶
AddMember takes a userID as an argument and adds them to the family It returns a non-nil error if they are already in the family
func (*Family) IsInFamily ¶
IsInFamily takes a userID argument, and returns true if that user is a member of the family, and false if they are not Might be worth converting to hashmap just to avoid this
func (*Family) RemoveElder ¶
RemoveElder demotes an elder to a regular old family member
type Group ¶
type Group struct { GroupName string `json:"name" html:"name"` GroupID string `json:"id" html:"id"` Family string `json:"family" html:"family"` Members []string `json:"members" html:"members"` Lists []string `json:"lists" html:"lists"` //just list IDs, same as with a member // contains filtered or unexported fields }
Group is an optional subgroup within families. Someday, I may even give groups to groups
func UnmarshalGroup ¶
UnmarshalGroup - Pretty straightforward here
func (*Group) AddMember ¶
AddMember takes a string argument for a user's login and adds that member to the group
func (*Group) RemoveMember ¶
RemoveMember removes a member from a group
type Member ¶
type Member struct { Login string `json:"login" html:"login"` //is this unsecure? Should I be storing the hash instead? Should I be storing at all? Password []byte `json:"password" html:"password"` //actual password won't be stored anywhere, just the hash OldPasswords [][]byte `json:"old_passwords" html:"old_passwords"` //should probably make this a tree at some point Username string `json:"username" html:"username"` UserID []byte `json:"id" html:"id"` Family []string `json:"family" html:"family"` FirstName string `json:"first_name" html:"first_name"` LastName string `json:"last_name" html:"last_name"` Groups []string `json:"groups" html:"groups"` GroupMap map[string]string `json:"group_map" html:"group_map"` ElderOf []string `json:"elder_of" html:"elder_of"` //need to tokenize this somehow Lists []string `json:"lists" html:"lists"` //these will be the values for the list ID database key. Maybe change to map, with family name as key? Messages []message `json:"messages" html:"messages"` // contains filtered or unexported fields }
Member is a member of a family. May also be a member of a group or several groups
func UnmarshalUser ¶
UnmarshalUser takes a slice of bytes and returns a user
func (*Member) ChangePassword ¶
ChangePassword changes a user's password. Note that security checks should already be handled at this point
func (*Member) RemoveList ¶
RemoveList takes a listID as input and removes it. It returns a non-nil error if the list is not found
type Messages ¶
type Messages struct { Owner string `json:"owner" html:"owner"` //this will be who is viewing these messages Messages []message `json:"messages" html:"messages"` //guess this works for now }
messages is a stack of messages. Each individual user will have their own message stack. This way, messages will be sorted once on sending, and we won't have to do any silly nonsense like
func (*Messages) DeleteMessage ¶
DeleteMessage deletes a message. It returns a non-nil error if no such message is found
func (*Messages) NewMessage ¶
func (me *Messages) NewMessage(m message)
type TokenMap ¶
tokenMap holds references to all outsanding tokens, and which family they match to
func NewTokenMap ¶
func NewTokenMap() *TokenMap