backend

package
v0.0.0-...-00f1f15 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2015 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCaptcha

func CheckCaptcha(db *periwinkle.Tx, userInput string, captchaID string) bool

func DbDrop

func DbDrop(db *periwinkle.Tx) locale.Error

func DbSchema

func DbSchema(db *periwinkle.Tx) locale.Error

func DbSeed

func DbSeed(db *periwinkle.Tx) locale.Error

func DeleteUnusedTwilioNumber

func DeleteUnusedTwilioNumber(db *periwinkle.Tx, num string) locale.Error

func GetTwilioNumberByUserAndGroup

func GetTwilioNumberByUserAndGroup(db *periwinkle.Tx, userid string, groupid string) string

func IsAdmin

func IsAdmin(db *periwinkle.Tx, userID string, group Group) bool

func IsSubscribed

func IsSubscribed(db *periwinkle.Tx, userID string, group Group) int

func PostJoin

func PostJoin(m [3]int) map[string]string

func RandomString

func RandomString(size int) string

func ReadExist

func ReadExist(m [2]int) map[string]string

func Reverse

func Reverse(m map[string]string) []int

func UseCaptcha

func UseCaptcha(db *periwinkle.Tx, id, token string) bool

Types

type Admin

type Admin struct {
	UserID string `json:"user_id"`
}

type Captcha

type Captcha struct {
	ID         string    `json:"-"`
	Value      string    `json:"value"`
	Token      string    `json:"-"`
	Expiration time.Time `json:"expiration_time"`
}

func GetCaptchaByID

func GetCaptchaByID(db *periwinkle.Tx, id string) *Captcha

func NewCaptcha

func NewCaptcha(db *periwinkle.Tx) *Captcha

func (*Captcha) MarshalPNG

func (o *Captcha) MarshalPNG(w io.Writer) locale.Error

func (*Captcha) MarshalWAV

func (o *Captcha) MarshalWAV(w io.Writer) locale.Error

func (*Captcha) Save

func (o *Captcha) Save(db *periwinkle.Tx)

type Group

type Group struct {
	ID                 string         `json:"group_id"`
	ReadPublic         int            `json:"readpublic"`
	ReadConfirmed      int            `json:"readconfirmed"`
	ExistencePublic    int            `json:"existencepublic"`
	ExistenceConfirmed int            `json:"existenceconfirmed"`
	PostPublic         int            `json:"postpublic"`
	PostConfirmed      int            `json:"postconformed"`
	PostMember         int            `json:"postmember"`
	JoinPublic         int            `json:"joinpublic"`
	JoinConfirmed      int            `json:"joinconfirmed"`
	JoinMember         int            `json:"joinmember"`
	Subscriptions      []Subscription `json:"subscriptions"`
}

A Group or mailing list that users may subscribe to.

func GetAllGroups

func GetAllGroups(db *periwinkle.Tx) []Group

func GetGroupByID

func GetGroupByID(db *periwinkle.Tx, id string) *Group

func GetGroupByUserAndTwilioNumber

func GetGroupByUserAndTwilioNumber(db *periwinkle.Tx, userid string, twilioNum string) *Group

func GetGroupsByMember

func GetGroupsByMember(db *periwinkle.Tx, user User) []Group

func GetPublicAndSubscribedGroups

func GetPublicAndSubscribedGroups(db *periwinkle.Tx, user User) []Group

func NewGroup

func NewGroup(db *periwinkle.Tx, name string, existence []int, read []int, post []int, join []int) *Group

func (*Group) Delete

func (grp *Group) Delete(db *periwinkle.Tx)

func (*Group) GetSubscriberIDs

func (grp *Group) GetSubscriberIDs(db *periwinkle.Tx) []string

func (*Group) GetSubscriptions

func (grp *Group) GetSubscriptions(db *periwinkle.Tx) []Subscription

func (*Group) Save

func (o *Group) Save(db *periwinkle.Tx)

type Medium

type Medium struct {
	ID string
}

type Message

type Message struct {
	ID      string
	GroupID string `json:"-" sql:"type:varchar(255) REFERENCES groups(id) ON DELETE CASCADE ON UPDATE RESTRICT"`
	Unique  string
}

func GetMessageByID

func GetMessageByID(db *periwinkle.Tx, id string) *Message

func NewMessage

func NewMessage(db *periwinkle.Tx, id string, group Group, unique maildir.Unique) Message

type Session

type Session struct {
	ID       string    `json:"session_id"`
	UserID   string    `json:"user_id" sql:"type:varchar(255) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE"`
	LastUsed time.Time `json:"-"`
}

func GetSessionByID

func GetSessionByID(db *periwinkle.Tx, id string) *Session

func NewSession

func NewSession(db *periwinkle.Tx, user *User, password string) *Session

func (*Session) Delete

func (o *Session) Delete(db *periwinkle.Tx)

func (*Session) Save

func (o *Session) Save(db *periwinkle.Tx)

type ShortURL

type ShortURL struct {
	ID   string
	Dest string //*url.URL // TODO: figure out how to have (un)marshalling happen automatically
}

func GetShortURLByID

func GetShortURLByID(db *periwinkle.Tx, id string) *ShortURL

func NewShortURL

func NewShortURL(db *periwinkle.Tx, u *url.URL) *ShortURL

func (*ShortURL) Save

func (o *ShortURL) Save(db *periwinkle.Tx)

type Subscription

type Subscription struct {
	AddressID int64  `sql:"type:bigint       REFERENCES user_addresses(id) ON DELETE CASCADE  ON UPDATE RESTRICT"`
	GroupID   string `sql:"type:varchar(255) REFERENCES groups(id)         ON DELETE CASCADE  ON UPDATE RESTRICT"`
	Confirmed bool
}

func NewSubscription

func NewSubscription(db *periwinkle.Tx, addressID int64, groupID string, confirmed bool) Subscription

func (*Subscription) Delete

func (sub *Subscription) Delete(db *periwinkle.Tx)

type TwilioNumber

type TwilioNumber struct {
	ID     int64  `json:"number_id"`
	Number string `json:"number"`
}

func GetAllUsedTwilioNumbers

func GetAllUsedTwilioNumbers(db *periwinkle.Tx) (ret []TwilioNumber)

func GetTwilioNumberByID

func GetTwilioNumberByID(db *periwinkle.Tx, id int64) *TwilioNumber

type TwilioPool

type TwilioPool struct {
	UserID   string `json:"user_id"   sql:"type:varchar(255) REFERENCES users(id)          ON DELETE CASCADE  ON UPDATE RESTRICT"`
	GroupID  string `json:"group_id"  sql:"type:varchar(255) REFERENCES groups(id)         ON DELETE CASCADE  ON UPDATE RESTRICT"`
	NumberID int64  `json:"number_id" sql:"type:bigint       REFERENCES twilio_numbers(id) ON DELETE RESTRICT ON UPDATE RESTRICT"`
}

func AssignTwilioNumber

func AssignTwilioNumber(db *periwinkle.Tx, userid string, groupid string, twilioNum string) *TwilioPool

func GetTwilioPoolByUserID

func GetTwilioPoolByUserID(db *periwinkle.Tx, userid string) []TwilioPool

type TwilioSMSMessage

type TwilioSMSMessage struct {
	MessageSID    string `json:"MessageSid" sql:"type:varchar(34)"`
	MessageStatus string
	ErrorCode     string
}

func GetTwilioSMSMessageBySID

func GetTwilioSMSMessageBySID(db *periwinkle.Tx, sid string) *TwilioSMSMessage

func (*TwilioSMSMessage) Delete

func (o *TwilioSMSMessage) Delete(db *periwinkle.Tx)

func (*TwilioSMSMessage) Save

func (o *TwilioSMSMessage) Save(db *periwinkle.Tx)

type User

type User struct {
	ID        string        `json:"user_id"`
	FullName  string        `json:"fullname"`
	PwHash    []byte        `json:"-"`
	Addresses []UserAddress `json:"addresses"`
}

func GetUserByAddress

func GetUserByAddress(db *periwinkle.Tx, medium string, address string) *User

func GetUserByID

func GetUserByID(db *periwinkle.Tx, id string) *User

func NewUser

func NewUser(db *periwinkle.Tx, name string, password string, email string) User

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) Delete

func (usr *User) Delete(db *periwinkle.Tx)

func (*User) GetFrontEndSubscriptions

func (u *User) GetFrontEndSubscriptions(db *periwinkle.Tx) []Subscription

func (*User) GetSubscriptions

func (u *User) GetSubscriptions(db *periwinkle.Tx) []Subscription

func (*User) Save

func (usr *User) Save(db *periwinkle.Tx)

func (*User) SetPassword

func (u *User) SetPassword(password string)

type UserAddress

type UserAddress struct {
	// TODO: add a "verified" boolean
	ID        int64  `json:"-"`
	UserID    string `json:"-"      sql:"type:varchar(255) REFERENCES users(id) ON DELETE CASCADE  ON UPDATE RESTRICT"`
	Medium    string `json:"medium" sql:"type:varchar(255) REFERENCES media(id) ON DELETE RESTRICT ON UPDATE RESTRICT"`
	Address   string `json:"address"`
	SortOrder uint64 `json:"sort_order"`
	Confirmed bool   `json:"confirmed"`
}

func GetAddressesByUserAndMedium

func GetAddressesByUserAndMedium(db *periwinkle.Tx, userID string, medium string) []UserAddress

func NewUserAddress

func NewUserAddress(db *periwinkle.Tx, userID string, medium string, address string, confirmed bool) UserAddress

func (UserAddress) AsEmailAddress

func (addr UserAddress) AsEmailAddress() string

func (*UserAddress) GetSubscriptions

func (addr *UserAddress) GetSubscriptions(db *periwinkle.Tx) []Subscription

Jump to

Keyboard shortcuts

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