Documentation ¶
Index ¶
- Constants
- type Attachment
- type Category
- type Comment
- type CommentStatus
- type Config
- type ConnectionPool
- func (pool *ConnectionPool) AddConnection(conn *websocket.Conn)
- func (pool *ConnectionPool) Authenticate(conn *websocket.Conn, user *User)
- func (pool *ConnectionPool) Broadcast(frame Frame)
- func (pool *ConnectionPool) DropConnection(conn *websocket.Conn)
- func (pool *ConnectionPool) Logout(user *User)
- func (pool *ConnectionPool) Send(to *User, frame Frame)
- func (pool *ConnectionPool) Write(conn *websocket.Conn, frame Frame)
- type Device
- type Frame
- type Model
- type Role
- type SMTP
- type Settings
- type Slugged
- type SocialProfile
- type SocketConnectionsMap
- type SocketStateMap
- type Topic
- type User
- type UserAuthData
- type UserConnectionsMap
- type UserList
Constants ¶
const ( PingFrame = "Ping" AuthFrame = "Auth" AuthErrorFrame = "AuthError" JWTFrame = "JWT" UserListFrame = "UserList" UserInfoFrame = "UserInfo" UserUpdateFrame = "UserUpdate" UserDeleteFrame = "UserDelete" CategoryFrame = "Category" CategoryListFrame = "CategoryList" CategorySaveFrame = "CategorySave" CategoryUpdateFrame = "CategoryUpdate" CategoryDeleteFrame = "CategoryDelete" CategoryErrorFrame = "CategoryError" TopicFrame = "Topic" TopicSaveFrame = "TopicSave" TopicListFrame = "TopicList" CommentFrame = "Comment" CommentListFrame = "CommentList" CommentSaveFrame = "CommentSave" UserFrame = "User" ResetPasswordFrame = "ResetPassword" FileUploadFrame = "Upload" CancelUploadFrame = "CancelUpload" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct { Model Type string `json:"type"` Title string `json:"title"` Description string `json:"description"` Link string `json:"link"` Thumbnail string `json:"thumbnail"` HTML string `json:"html"` }
Attachment for comment
type Category ¶
type Category struct { Model Name string `json:"name"` Slug string `sql:"index" json:"slug"` Description string `json:"description" sql:"type:text"` Order int `json:"order"` Active bool `json:"active"` Updates int `json:"updates"` }
Category of topics
type Comment ¶
type Comment struct { Model TopicID uint `json:"topicId" sql:"index"` Topic Topic `json:"topic,omitempty" gorm:"association_autoupdate:false;association_autocreate:false"` UserID uint `json:"userId" sql:"index"` User User `json:"user" gorm:"association_autoupdate:false;association_autocreate:false"` Body string `json:"body" sql:"type:text"` Attachments []Attachment `json:"attachments,omitempty" gorm:"association_autoupdate:false;association_autocreate:false"` Rank uint `json:"rank"` Solution bool `json:"solution"` Spam bool `json:"spam"` Moderated bool `json:"moderated"` }
Comment on the topic
type CommentStatus ¶
type CommentStatus struct { Model CommentID uint `json:"commentId"` Comment Topic `json:"comment" gorm:"association_autoupdate:false;association_autocreate:false"` UserID uint `json:"userId" sql:"index"` User User `json:"user" gorm:"association_autoupdate:false;association_autocreate:false"` ReadAt *time.Time `json:"readAt"` NotifiedAt *time.Time `json:"notifiedAt"` Vote int `json:"vote"` }
CommentStatus used to track read statuses of comments
type Config ¶
type Config struct { ID uint `gorm:"primary_key" json:"id"` JwtSignature []byte `gorm:"type:varbinary(256)"` Protocol string Port uint Name string Domain string LogoPath string UploadDir string DocumentRoot string SMTP SMTP `gorm:"embedded;embedded_prefix:smtp_"` Debug bool }
Config defines app configuration
type ConnectionPool ¶
type ConnectionPool struct { Sockets SocketConnectionsMap Users UserConnectionsMap // contains filtered or unexported fields }
ConnectionPool is intended to keep track of all connections
func NewConnectionPool ¶
func NewConnectionPool() *ConnectionPool
NewConnectionPool is factory to create new pool of connections
func (*ConnectionPool) AddConnection ¶
func (pool *ConnectionPool) AddConnection(conn *websocket.Conn)
AddConnection adds connection to the pool
func (*ConnectionPool) Authenticate ¶
func (pool *ConnectionPool) Authenticate(conn *websocket.Conn, user *User)
Authenticate binds user identifier to a connection
func (*ConnectionPool) Broadcast ¶
func (pool *ConnectionPool) Broadcast(frame Frame)
Broadcast sends a frame to all connections
func (*ConnectionPool) DropConnection ¶
func (pool *ConnectionPool) DropConnection(conn *websocket.Conn)
DropConnection closes connection
func (*ConnectionPool) Logout ¶
func (pool *ConnectionPool) Logout(user *User)
Logout disaccosiates users and connections
func (*ConnectionPool) Send ¶
func (pool *ConnectionPool) Send(to *User, frame Frame)
Send delivers a frame to all user's connections
type Device ¶
type Device struct { UserID uint DeviceID string Type string // browser, phone UserAgent string LastIP net.Addr AccessAt time.Time Subscribed bool PushEndpoint string PushKeyP256 string PushAuth string }
Device describes the device used by the user
type Frame ¶
type Model ¶
type SMTP ¶
type SMTP struct { From string Host string Port int Username string Password string InsecureTLS bool SSL bool }
SMTP used to define SMTP configuration
type Settings ¶
type Settings struct { // Offline Notifications: // 0. No // 1. Push only // 2. Immediate to email // 3. Daily email digests // 4. Weekly email digests UserID uint Notifications uint Timezone time.Location }
Settings keep user settings under control
type SocialProfile ¶
type SocialProfile struct { Model NetworkID string `json:"networkId"` Network string `json:"name"` Token string `json:"-"` ExpiresAt time.Time `json:"-"` UserID uint }
SocialProfile represents user profile in social networks
type SocketConnectionsMap ¶
SocketConnectionsMap type
type Topic ¶
type Topic struct { Model Slugged CategoryID uint `json:"categoryId"` Category Category `json:"category,omitempty" gorm:"association_autoupdate:false;association_autocreate:false"` UserID uint `json:"userId"` User User `json:"user,omitempty" gorm:"association_autoupdate:false;association_autocreate:false"` Title string `json:"title"` Body string `json:"body,omitempty" sql:"type:longtext"` Order int `json:"order"` ACL []User `json:"acl" gorm:"many2many:topic_acl;association_autoupdate:false;association_autocreate:false"` TotalViews uint32 `json:"total_views,omitempty"` TotalComments uint32 `json:"total_comments,omitempty"` Rank uint32 `json:"rank,omitempty"` Private bool `json:"private"` Pinned bool `json:"pinned"` }
Topic defines the main forum topic structure
func (*Topic) BeforeCreate ¶
BeforeCreate hook
type User ¶
type User struct { Model Email string `validator:"email" gorm:"unique_index" json:"email,omitempty"` EmailVerified bool `gorm:"default:false" json:"email_verified,omitempty"` Password string `json:"-"` Hash string `json:"-"` Name string `json:"name"` Slug string `json:"slug" gorm:"unique_index"` Picture string `json:"picture"` About string `json:"about,omitempty"` Gender string `json:"gender,omitempty"` Rank float32 `json:"rank"` Online bool `json:"online"` Roles []Role `json:"roles,omitempty"` Profiles []SocialProfile `json:"profiles,omitempty" gorm:"[]"` Devices []Device `json:"devices,omitempty"` Settings *Settings `json:"settings,omitempty"` }
User represents user entity
func (*User) MakeGravatarPicture ¶
MakeGravatarPicture method
type UserAuthData ¶
type UserAuthData struct { Email string `json:"email"` Password string `json:"password"` RememberMe bool `json:"rememberMe"` }
UserAuthData packet