Documentation
¶
Index ¶
- Constants
- Variables
- func AlertTeamOfMentions(roomId, body string, mentions []string) error
- func CreateMessage(fields *Message) error
- func DeleteRoom(slug, teamId string) error
- func DeleteRoomMembership(roomId, userId string) error
- func FindRoomMemberships(userId string) ([]string, error)
- func NewDbContext(url string) *gorp.DbMap
- func NonceValid(nonce string) bool
- func ParseMessage(message *Message) string
- func PostToTeamWebhook(roomId string, message *Message) error
- func ShaString(raw []byte) string
- func Sign(secret, payload []byte) string
- func Subscribers(roomId string) (*[]string, error)
- func SubscribersWithoutUser(roomId, userId string) (*[]string, error)
- func TouchUser(userId string)
- func UnreadRooms(userId string) (interface{}, error)
- type Message
- type MessageWithUser
- type Nonce
- type Room
- type RoomMembership
- type SSORequest
- type Team
- type UnreadAlert
- type User
- func FindOrCreateUserByExternalId(fields *User) (*User, error)
- func FindRecentlyOnlineUsers(teamId string) ([]User, error)
- func FindUser(id string) (*User, error)
- func FindUserByExternalIDAndTeam(externalID, teamID string) (*User, error)
- func FindUserByUsernameAndTeam(username, teamId string) (*User, error)
- func FindUsers(teamId string) ([]User, error)
- func SearchUsersByUsernameLike(partialUsername, teamId string) ([]User, error)
Constants ¶
View Source
const (
NonceBytes = 32
)
Variables ¶
View Source
var ( // Db is the global database context Db = NewDbContext(os.Getenv("DATABASE_URL")) )
Functions ¶
func AlertTeamOfMentions ¶
func CreateMessage ¶
func DeleteRoom ¶
func DeleteRoomMembership ¶
func FindRoomMemberships ¶
func NewDbContext ¶
func NewDbContext(url string) *gorp.DbMap
NewDbContext initialises a new database context
func NonceValid ¶
func ParseMessage ¶
ParseMessage parses the outgoing message by catching user and room mentions, URLs, and then passing the body through Blackfriday for additional parsing and finally Bluemonday for sanitization.
func PostToTeamWebhook ¶
func Subscribers ¶
func SubscribersWithoutUser ¶
func UnreadRooms ¶
Types ¶
type Message ¶
type MessageWithUser ¶
type MessageWithUser struct { Id string `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` Body string `db:"body" json:"body"` HTMLBody string `json:"html_body"` Username string `db:"username" json:"username"` AvatarUrl string `db:"avatar_url" json:"avatar_url"` LastOnlineAt time.Time `db:"last_online_at" json:"last_online_at"` ProfileUrl string `db:"profile_url" json:"profile_url"` }
func FindMessages ¶
func FindMessages(roomId string) ([]MessageWithUser, error)
func FindMessagesBeforeTimestamp ¶
func FindMessagesBeforeTimestamp(roomId string, timestamp time.Time) ([]MessageWithUser, error)
func NewMessageWithUser ¶
func NewMessageWithUser(message *Message, user *User) *MessageWithUser
NewMessageWithUser parses the message body and joins the user to it
type Nonce ¶
type Nonce struct { Id string `db:"id" json:"-"` ExpiresAt time.Time `db:"expires_at" json:"expires_at"` Nonce string `db:"nonce" json:"nonce"` }
func CreateNonce ¶
type Room ¶
type Room struct { Id string `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` DeletedAt *time.Time `db:"deleted_at" json:"deleted_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` TeamId string `db:"team_id" json:"team_id"` Slug string `db:"slug" json:"slug"` Topic string `db:"topic" json:"topic"` }
func FindOrCreateRoom ¶
func FindRoomById ¶
type RoomMembership ¶
type RoomMembership struct { Id string `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` DeletedAt *time.Time `db:"deleted_at" json:"deleted_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` RoomId string `db:"room_id" json:"room_id"` UserId string `db:"user_id" json:"user_id"` }
func FindOrCreateRoomMembership ¶
func FindOrCreateRoomMembership(fields *RoomMembership) (*RoomMembership, error)
func (*RoomMembership) PreInsert ¶
func (o *RoomMembership) PreInsert(s gorp.SqlExecutor) error
func (*RoomMembership) PreUpdate ¶
func (o *RoomMembership) PreUpdate(s gorp.SqlExecutor) error
type SSORequest ¶
type SSORequest struct { Payload string Signature string Nonce string TeamSlug string ExternalId string AvatarUrl string Username string Email string ProfileUrl string RealName string }
func (*SSORequest) IsValid ¶
func (r *SSORequest) IsValid(secret string) bool
type Team ¶
type Team struct { Id string `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` Email string `db:"email" json:"email"` EncryptedPassword string `db:"encrypted_password" json:"encrypted_password"` SSOSecret string `db:"sso_secret" json:"-"` SSOUrl string `db:"sso_url" json:"sso_url"` Slug string `db:"slug" json:"slug"` WebhookURL *string `db:"webhook_url" json:"webhook_url"` }
func FindOrCreateTeam ¶
func FindTeamById ¶
func FindTeamBySecret ¶
func FindTeamBySlug ¶
type UnreadAlert ¶
type User ¶
type User struct { Id string `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` LastOnlineAt time.Time `db:"last_online_at" json:"last_online_at"` TeamId string `db:"team_id" json:"team_id"` AvatarUrl string `db:"avatar_url" json:"avatar_url"` Email string `db:"email" json:"email"` ExternalId string `db:"external_id" json:"external_id"` ProfileUrl string `db:"profile_url" json:"profile_url"` RealName string `db:"real_name" json:"real_name"` Username string `db:"username" json:"username"` }
func FindRecentlyOnlineUsers ¶
Click to show internal directories.
Click to hide internal directories.