Documentation ¶
Index ¶
- Constants
- func HashPassword(plaintextPassword string) (string, error)
- type FindMessagesParameters
- type Mailbox
- type MailboxRepository
- func (r *MailboxRepository) CreateMailbox(mailbox *Mailbox) error
- func (r *MailboxRepository) DeleteMailbox(id uint) error
- func (r *MailboxRepository) DeleteMailboxByUserIDAndMailboxName(userID uint, mailboxName string) error
- func (r *MailboxRepository) FindMailboxesByUserID(userID uint) ([]*Mailbox, error)
- func (r *MailboxRepository) GetMailBoxByUserIDAndMailboxName(userID uint, mailboxName string) (*Mailbox, error)
- func (r *MailboxRepository) GetMailboxByID(id uint) (*Mailbox, error)
- func (r *MailboxRepository) UpdateMailbox(mailbox *Mailbox) error
- type Message
- type MessageRepository
- func (r *MessageRepository) CreateMessage(message *Message) error
- func (r *MessageRepository) DeleteMessageByID(id uint) error
- func (r *MessageRepository) FindMessagesByMailboxID(mailboxID uint, parameters FindMessagesParameters) ([]*Message, error)
- func (r *MessageRepository) GetMessageByID(id uint) (*Message, error)
- func (r *MessageRepository) GetNextMessageID(mailboxID uint) (uint, error)
- func (r *MessageRepository) GetNumberOfMessagesByMailboxID(mailboxID uint) (uint, error)
- func (r *MessageRepository) GetTotalMessagesCount() (int64, error)
- func (r *MessageRepository) UpdateMessage(message *Message) error
- type Sequence
- type StringSlice
- type User
- type UserRepository
- func (r *UserRepository) CreateUser(user *User) error
- func (r *UserRepository) DeleteUser(id uint) error
- func (r *UserRepository) FindUserByEmail(email string) (*User, error)
- func (r *UserRepository) GetAllUsers() ([]*User, error)
- func (r *UserRepository) GetTotalUsersCount() (int64, error)
- func (r *UserRepository) GetUserByID(id uint) (*User, error)
- func (r *UserRepository) UpdateUser(user *User) error
Constants ¶
const MessageWithSequenceNumberViewName = "messages_sequence_numbers"
MessageWithSequenceNumberViewName is the name of the view that represents all messages with their corresponding sequence number.
const MessageWithSequenceNumberViewQuery = `` /* 138-byte string literal not displayed */
MessageWithSequenceNumberViewQuery query that selects this view.
Variables ¶
This section is empty.
Functions ¶
func HashPassword ¶
HashPassword hashes a password.
Types ¶
type FindMessagesParameters ¶
type FindMessagesParameters struct { // SequenceSet is a list of sequences with sequence numbers. SequenceSet []Sequence // UIDSet is a list of sequences with uids. UIDSet []Sequence // OmitBody excludes the email body in the message if set to true. OmitBody bool }
FindMessagesParameters are optional parameters that can be used to get/find messages.
type Mailbox ¶
type Mailbox struct { gorm.Model ID uint `gorm:"primary_key;auto_increment;not_null"` Subscribed bool Name string `gorm:"index:idx_mailbox_user,unique"` UserID uint `gorm:"index:idx_mailbox_user,unique;foreignKey:User"` User *User }
Mailbox represent a mailbox.
type MailboxRepository ¶
type MailboxRepository struct {
// contains filtered or unexported fields
}
MailboxRepository implements the Mailbox repository
func NewMailboxRepository ¶
func NewMailboxRepository(db *gorm.DB) (*MailboxRepository, error)
NewMailboxRepository creates a new MailboxRepository
func (*MailboxRepository) CreateMailbox ¶
func (r *MailboxRepository) CreateMailbox(mailbox *Mailbox) error
CreateMailbox creates a new mailbox in the database.
func (*MailboxRepository) DeleteMailbox ¶
func (r *MailboxRepository) DeleteMailbox(id uint) error
DeleteMailbox deletes a mailbox from the database by its ID.
func (*MailboxRepository) DeleteMailboxByUserIDAndMailboxName ¶
func (r *MailboxRepository) DeleteMailboxByUserIDAndMailboxName(userID uint, mailboxName string) error
DeleteMailboxByUserIDAndMailboxName deletes a mailbox from the database by user ID and mailbox name.
func (*MailboxRepository) FindMailboxesByUserID ¶
func (r *MailboxRepository) FindMailboxesByUserID(userID uint) ([]*Mailbox, error)
FindMailboxesByUserID finds mailboxes in the database by their user ID.
func (*MailboxRepository) GetMailBoxByUserIDAndMailboxName ¶
func (r *MailboxRepository) GetMailBoxByUserIDAndMailboxName(userID uint, mailboxName string) (*Mailbox, error)
GetMailBoxByUserIDAndMailboxName retrieves a mailbox from the database by user ID and mailbox name.
func (*MailboxRepository) GetMailboxByID ¶
func (r *MailboxRepository) GetMailboxByID(id uint) (*Mailbox, error)
GetMailboxByID retrieves a mailbox from the database by its ID.
func (*MailboxRepository) UpdateMailbox ¶
func (r *MailboxRepository) UpdateMailbox(mailbox *Mailbox) error
UpdateMailbox updates an existing mailbox in the database.
type Message ¶
type Message struct { gorm.Model ID uint `gorm:"primary_key;auto_increment;not_null"` Date time.Time Size uint32 Flags StringSlice Body []byte MailboxID uint `gorm:"foreignKey:Mailbox"` SequenceNumber uint `gorm:"->;-:migration"` // read only and skip in migrations because its the column from a view. }
Message represents an email message.
type MessageRepository ¶
type MessageRepository struct {
// contains filtered or unexported fields
}
MessageRepository implements the Message repository
func NewMessageRepository ¶
func NewMessageRepository(db *gorm.DB) (*MessageRepository, error)
NewMessageRepository creates a new MessageRepository
func (*MessageRepository) CreateMessage ¶
func (r *MessageRepository) CreateMessage(message *Message) error
CreateMessage creates a new message in the database.
func (*MessageRepository) DeleteMessageByID ¶
func (r *MessageRepository) DeleteMessageByID(id uint) error
DeleteMessageByID deletes a message from the database by its ID.
func (*MessageRepository) FindMessagesByMailboxID ¶
func (r *MessageRepository) FindMessagesByMailboxID(mailboxID uint, parameters FindMessagesParameters) ([]*Message, error)
FindMessagesByMailboxID finds messages in the database by their mailbox ID.
func (*MessageRepository) GetMessageByID ¶
func (r *MessageRepository) GetMessageByID(id uint) (*Message, error)
GetMessageByID retrieves a message from the database by its ID.
func (*MessageRepository) GetNextMessageID ¶
func (r *MessageRepository) GetNextMessageID(mailboxID uint) (uint, error)
GetNextMessageID gets the next available message id.
func (*MessageRepository) GetNumberOfMessagesByMailboxID ¶
func (r *MessageRepository) GetNumberOfMessagesByMailboxID(mailboxID uint) (uint, error)
GetNumberOfMessagesByMailboxID counts the number of messages in the given mailbox.
func (*MessageRepository) GetTotalMessagesCount ¶
func (r *MessageRepository) GetTotalMessagesCount() (int64, error)
GetTotalMessagesCount returns the total number of messages in the database.
func (*MessageRepository) UpdateMessage ¶
func (r *MessageRepository) UpdateMessage(message *Message) error
UpdateMessage updates an existing message in the database.
type Sequence ¶
type Sequence struct { // Start denotes the beginning of the range (inclusive) Start int // Stop denotes the end of the range (inclusive) Stop int }
Sequence represents a sequence of messages going from Start to Stop.
type StringSlice ¶
type StringSlice []string
func (*StringSlice) Scan ¶
func (ss *StringSlice) Scan(src interface{}) error
type User ¶
type User struct { gorm.Model ID uint `gorm:"primary_key;auto_increment;not_null"` Username string `gorm:"unique;not_null"` Password string `gorm:"not_null" json:"-"` Email string `gorm:"unique;not_null"` }
User represents an email user.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository implements the User repository
func NewUserRepository ¶
func NewUserRepository(db *gorm.DB) (*UserRepository, error)
NewUserRepository creates a new UserRepository
func (*UserRepository) CreateUser ¶
func (r *UserRepository) CreateUser(user *User) error
CreateUser creates a new user in the database.
func (*UserRepository) DeleteUser ¶
func (r *UserRepository) DeleteUser(id uint) error
DeleteUser deletes a user from the database by their ID.
func (*UserRepository) FindUserByEmail ¶
func (r *UserRepository) FindUserByEmail(email string) (*User, error)
FindUserByEmail finds a user in the database by their email address.
func (*UserRepository) GetAllUsers ¶
func (r *UserRepository) GetAllUsers() ([]*User, error)
GetAllUsers retrieves all users from the database.
func (*UserRepository) GetTotalUsersCount ¶
func (r *UserRepository) GetTotalUsersCount() (int64, error)
GetTotalUsersCount returns the total number of users in the database.
func (*UserRepository) GetUserByID ¶
func (r *UserRepository) GetUserByID(id uint) (*User, error)
GetUserByID retrieves a user from the database by their ID.
func (*UserRepository) UpdateUser ¶
func (r *UserRepository) UpdateUser(user *User) error
UpdateUser updates an existing user in the database.