Documentation ¶
Overview ¶
Package models provides interfaces to perform CRUD actions to underlying data and a LRU cache layer for data returned.
Index ¶
- Constants
- Variables
- func AnchorRelativeUrls(siteID int64, bodyText string) string
- func CheckSiteResource(resource string, site SiteType) error
- func CleanBlockText(s string) string
- func CleanSentence(s string, preventShouting bool) string
- func CleanWord(s string) string
- func CreateOwnedSite(site SiteType, user UserType) (SiteType, ProfileType, int, error)
- func CreateRevisionLink(db *sql.DB, revisionID int64, linkID int64) error
- func DecrementItemCommentCount(itemTypeID int64, itemID int64)
- func DecrementMicrocosmItemCount(tx *sql.Tx, microcosmID int64) error
- func DecrementProfileCommentCount(profileID int64)
- func DeleteAttachment(itemTypeID int64, itemID int64, fileHash string) (int, error)
- func DeleteManyAttributes(itemTypeID int64, itemID int64, ms []AttributeType) (int, error)
- func DeleteManyRoleCriteria(roleID int64, ems []RoleCriterionType) (int, error)
- func DeleteManyRoleProfiles(roleID int64, ems []RoleProfileType) (int, error)
- func DeleteMenu(siteID int64) (int, error)
- func DeleteOldUpdates()
- func DeleteOrphanedHuddles()
- func EmbedAllMedia(revisionID int64) (int, error)
- func FetchProfileID(tx *sql.Tx, profileName string, revisionID int64) int64
- func FlushRoleMembersCacheByProfileID(tx *sql.Tx, profileID int64) (int, error)
- func FlushRoleMembersCacheByRoleID(tx *sql.Tx, roleID int64) (int, error)
- func FormatAsJSON(c *Context, input interface{}) ([]byte, error)
- func ForumMetrics() (total int, engaged int, err error)
- func GetAttendeeID(eventID int64, profileID int64) (int64, int, error)
- func GetAttendeesCSV(siteID int64, eventID int64, profileID int64) (string, int, error)
- func GetAttributeID(itemTypeID int64, itemID int64, key string) (int64, int, error)
- func GetComments(siteID int64, itemType string, itemID int64, reqURL *url.URL, profileID int64, ...) (h.ArrayType, int, error)
- func GetFile(fileHash string) ([]byte, map[string]string, int, error)
- func GetHuddleTitle(id int64) string
- func GetItemCacheKeys(itemTypeID int64) map[int]string
- func GetItems(siteID int64, microcosmID int64, profileID int64, reqURL *url.URL) (h.ArrayType, int, error)
- func GetLastReadTime(itemTypeID int64, itemID int64, profileID int64) (time.Time, int, error)
- func GetLatestComments(siteID int64, itemType string, itemID int64, profileID int64, limit int64) (int64, int64, int, error)
- func GetMenu(siteID int64) ([]h.LinkType, int, error)
- func GetMicrocosmIDForItem(itemTypeID int64, itemID int64) int64
- func GetMicrocosmTitle(id int64) string
- func GetNextOrLastCommentID(itemTypeID int64, itemID int64, timestamp time.Time, profileID int64) (int64, int, error)
- func GetPageNumber(commentID int64, limit int64, profileID int64) (int64, int64, int64, int, error)
- func GetProfileEmail(siteID int64, profileID int64) (email string)
- func GetProfileID(siteID int64, userID int64) (int64, int, error)
- func GetRawCookiePolicyText() string
- func GetRawPrivacyPolicyText() string
- func GetRawTermsOfServiceText() string
- func GetRawTermsOfUseText() string
- func GetRequestIP(req *http.Request) net.IP
- func GetRootMicrocosmID(id int64) int64
- func GetSiteStats(siteID int64) ([]h.StatType, error)
- func GetSiteTitle(id int64) string
- func GetSummary(siteID int64, itemTypeID int64, itemID int64, profileID int64) (interface{}, int, error)
- func GetTitle(siteID int64, itemTypeID int64, itemID int64, profileID int64) (string, int, error)
- func GetWatcherAndIgnoreStatus(itemTypeID int64, itemID int64, profileID int64) (int64, bool, bool, bool, int, error)
- func HandleAttendeeRequest(siteID int64, id int64, seq int, out chan<- AttendeeRequest)
- func HandleAttributeRequest(id int64, seq int, out chan<- AttributeRequest)
- func HandleCommentRequest(siteID int64, commentID int64, seq int, out chan<- CommentSummaryRequest)
- func HandleMicrocosmSummaryRequest(siteID int64, id int64, profileID int64, seq int, ...)
- func HandleProfileSummaryRequest(siteID int64, id int64, seq int, out chan<- ProfileSummaryRequest)
- func HandleRoleCriterionRequest(id int64, roleID int64, seq int, out chan<- RoleCriterionRequest)
- func HandleSummaryContainerRequest(siteID int64, itemTypeID int64, itemID int64, profileID int64, seq int, ...)
- func IncrementItemCommentCount(itemTypeID int64, itemID int64)
- func IncrementMicrocosmItemCount(tx *sql.Tx, microcosmID int64) error
- func IncrementProfileCommentCount(profileID int64)
- func IncrementViewCount(itemTypeID int64, itemID int64)
- func IsAttending(profileID int64, eventID int64) (bool, error)
- func IsBanned(siteID int64, userID int64) bool
- func IsProfileNameTaken(siteID int64, userID int64, profileName string) (bool, int, error)
- func IsReservedSubdomain(query string) (bool, error)
- func IsSpammer(email string) bool
- func MakeGravatarURL(email string) string
- func ManageUsers(site SiteType, ems []UserMembership) (int, error)
- func MarkAllAsRead(profileID int64) (int, error)
- func MarkAllHuddlesForAllProfilesAsReadOnSite(siteID int64) error
- func MarkAllMicrocosmsForAllProfilesAsReadOnSite(siteID int64) error
- func MarkAsRead(itemTypeID int64, itemID int64, profileID int64, updateTime time.Time) (int, error)
- func MarkScopeAsRead(profileID int64, rs ReadScopeType) (int, error)
- func MarkdownToHTML(src []byte) []byte
- func MergeAndSendEmail(siteID int64, from string, to string, subjectTemplate *template.Template, ...) (int, error)
- func ParseLinks(revisionID int64, site SiteType, element *html.Node, links *[]Link) error
- func PreProcessMentions(md []byte) []byte
- func ProcessBBCode(src []byte) []byte
- func ProcessCommentMarkdown(tx *sql.Tx, revisionID int64, markdown string, siteID int64, itemTypeID int64, ...) (string, error)
- func ProcessHashtags(siteID int64, src []byte) []byte
- func ProcessLinks(revisionID int64, src []byte, siteID int64) ([]byte, error)
- func ProcessMention(tx *sql.Tx, commentID int64, revisionID int64, createdBy int64, ...) error
- func ProcessMentions(tx *sql.Tx, revisionID int64, src []byte, siteID int64, itemTypeID int64, ...) ([]byte, error)
- func ProfileMetrics(start time.Time) (created int, edited int, total int, err error)
- func PurgeCache(itemTypeID int64, itemID int64)
- func PurgeCacheByScope(scope int, itemTypeID int64, itemID int64)
- func RegisterWatcher(profileID int64, updateTypeID int64, itemID int64, itemTypeID int64, ...) (bool, int, error)
- func SanitiseHTML(b []byte) []byte
- func SendUpdatesForEventReminder(siteID int64, event *EventType) (int, error)
- func SendUpdatesForNewAttendeeInAnEvent(siteID int64, attendee AttendeeType) (int, error)
- func SendUpdatesForNewCommentInHuddle(siteID int64, comment CommentSummaryType) (int, error)
- func SendUpdatesForNewCommentInItem(siteID int64, comment CommentSummaryType) (int, error)
- func SendUpdatesForNewItemInAMicrocosm(siteID int64, item interface{}) (int, error)
- func SendUpdatesForNewMentionInComment(siteID int64, forProfileID int64, commentID int64) (int, error)
- func SendUpdatesForNewReplyToYourComment(siteID int64, comment CommentSummaryType) (int, error)
- func SendUpdatesForNewUserOnSite(site SiteType, profile ProfileType, user UserType) (int, error)
- func SendUpdatesForNewVoteInAPoll(siteID int64, poll *PollType) (int, error)
- func SendUsage(c *Context, statusCode int, contentLength int, dur time.Duration, ...)
- func SetCommentInReplyTo(siteID int64, commentID int64, inReplyTo int64) error
- func ShortenLink(revisionID int64, fullURL string, host string, site SiteType, text string, ...) (string, string, string, error)
- func SuggestProfileName(user UserType) string
- func UnmarshalForm(form url.Values, v interface{}) error
- func UpdateAllSiteStats()
- func UpdateCommentCountForAllProfiles(siteID int64) (int, error)
- func UpdateEmbedsForDomain(domain string) (int, error)
- func UpdateLastActive(profileID int64, lastActive time.Time) (int, error)
- func UpdateManyAttendees(siteID int64, ems []AttendeeType) (int, error)
- func UpdateManyAttributes(itemTypeID int64, itemID int64, ems []AttributeType) (int, error)
- func UpdateManyHuddleParticipants(siteID int64, huddleID int64, ems []HuddleParticipantType) (int, error)
- func UpdateManyRoleProfiles(siteID int64, roleID int64, ems []RoleProfileType) (int, error)
- func UpdateMenu(siteID int64, ems []h.LinkType) (int, error)
- func UpdateMetrics() error
- func UpdateMetricsCron()
- func UpdateMicrocosmItemCounts()
- func UpdateProfileCounts()
- func UpdateSiteStats(siteID int64) error
- func UpdateUnreadHuddleCount(profileID int64)
- func UpdateViewCounts()
- func UpdateWhosOnline()
- func UserGenMetrics(start time.Time) (signins int, comments int, convs int, err error)
- func UserIsOnSite(userID int64, siteID int64) bool
- func ValidateProfileName(name string) (string, int, error)
- type AccessTokenRequestType
- type AccessTokenType
- type AttachmentType
- func AttachAvatar(profileID int64, fileMetadata FileMetadataType) (AttachmentType, int, error)
- func GetAttachment(itemTypeID int64, itemID int64, fileHash string, latest bool) (AttachmentType, int, error)
- func GetAttachments(itemTypeID int64, itemID int64, limit int64, offset int64) ([]AttachmentType, int64, int64, int, error)
- type AttachmentsType
- type AttendeeRequest
- type AttendeeRequestBySeq
- type AttendeeType
- type AttendeesType
- type AttributeRequest
- type AttributeRequestBySeq
- type AttributeType
- type AttributesType
- type AuthContext
- type AuthType
- type CommentFlagsMetaType
- type CommentFlagsType
- type CommentMetaType
- type CommentRequestBySeq
- type CommentSummaryRequest
- type CommentSummaryType
- func (m *CommentSummaryType) CreateCommentRevision(tx *sql.Tx, isFirst bool, siteID int64, itemTypeID int64, itemID int64, ...) (int64, int, error)
- func (m *CommentSummaryType) Delete(siteID int64) (int, error)
- func (m *CommentSummaryType) GetPageLink(limit int64, profileID int64) (h.LinkType, int, error)
- func (m *CommentSummaryType) Hydrate(siteID int64) (int, error)
- func (m *CommentSummaryType) Import(siteID int64) (int, error)
- func (m *CommentSummaryType) Insert(siteID int64) (int, error)
- func (m *CommentSummaryType) Patch(siteID int64, ac AuthContext, patches []h.PatchType) (int, error)
- func (m *CommentSummaryType) Update(siteID int64) (int, error)
- func (m *CommentSummaryType) Validate(siteID int64, exists bool) (int, error)
- type CommentType
- type CommentsType
- type Context
- func (c *Context) Fill(v interface{}) error
- func (c *Context) GetHTTPMethod() string
- func (c *Context) GetItemTypeAndItemID() (string, int64, int64, int, error)
- func (c *Context) IsRootSite() bool
- func (c *Context) Respond(data interface{}, statusCode int, errors []string, context *Context) error
- func (c *Context) RespondWithData(data interface{}) error
- func (c *Context) RespondWithError(statusCode int) error
- func (c *Context) RespondWithErrorDetail(err error, statusCode int) error
- func (c *Context) RespondWithErrorMessage(message string, statusCode int) error
- func (c *Context) RespondWithLocation(location string) error
- func (c *Context) RespondWithMoved(location string) error
- func (c *Context) RespondWithNotFound() error
- func (c *Context) RespondWithNotImplemented() error
- func (c *Context) RespondWithOK() error
- func (c *Context) RespondWithOptions(options []string) error
- func (c *Context) RespondWithSeeOther(location string) error
- func (c *Context) RespondWithStatus(statusCode int) error
- func (c *Context) WriteResponse(output []byte, statusCode int) error
- type ConversationSummaryType
- type ConversationType
- func (m *ConversationType) Delete() (int, error)
- func (m *ConversationType) Hydrate(siteID int64) (int, error)
- func (m *ConversationType) Import(siteID int64, profileID int64) (int, error)
- func (m *ConversationType) Insert(siteID int64, profileID int64) (int, error)
- func (m *ConversationType) Patch(ac AuthContext, patches []h.PatchType) (int, error)
- func (m *ConversationType) Update(siteID int64, profileID int64) (int, error)
- func (m *ConversationType) Validate(siteID int64, profileID int64, exists bool, isImport bool) (int, error)
- type ConversationsType
- type EmailMergeData
- type EmailType
- type EventSummaryType
- type EventType
- func (m *EventType) Delete() (int, error)
- func (m *EventType) GetAttending(profileID int64) (int, error)
- func (m *EventType) Hydrate(siteID int64) (int, error)
- func (m *EventType) Insert(siteID int64, profileID int64) (int, error)
- func (m *EventType) Patch(ac AuthContext, patches []h.PatchType) (int, error)
- func (m *EventType) Update(siteID int64, profileID int64) (int, error)
- func (m *EventType) UpdateAttendees(tx *sql.Tx) (int, error)
- func (m *EventType) Validate(siteID int64, profileID int64, exists bool) (int, error)
- type EventsType
- type FileMetadataType
- func (f *FileMetadataType) Import(maxWidth int64, maxHeight int64) (int, error)
- func (f *FileMetadataType) Insert(maxWidth int64, maxHeight int64) (int, error)
- func (f *FileMetadataType) ResizeImage(maxWidth int64, maxHeight int64) (int, error)
- func (f *FileMetadataType) Update() (int, error)
- func (f *FileMetadataType) Validate() (int, error)
- type FormRequestDecoder
- type HuddleParticipantType
- type HuddleParticipantsType
- type HuddleSummaryType
- type HuddleType
- func (m *HuddleType) Delete(siteID int64, profileID int64) (int, error)
- func (m *HuddleType) GetLink() string
- func (m *HuddleType) Hydrate(siteID int64) (int, error)
- func (m *HuddleType) Import(siteID int64) (int, error)
- func (m *HuddleType) Insert(siteID int64) (int, error)
- func (m *HuddleType) Validate(siteID int64, exists bool) (int, error)
- type HuddlesType
- type IgnoreType
- type IgnoredType
- type Item
- type ItemDetail
- type ItemDetailCommentsAndMeta
- type ItemParent
- type ItemRequest
- type ItemRequestBySeq
- type ItemSummary
- type ItemSummaryMeta
- type JSONRequestDecoder
- type LastComment
- type LegalData
- type LegalDoc
- type Link
- type MenuType
- type MetricType
- type MicrocosmCore
- type MicrocosmLinkType
- type MicrocosmSummaryRequest
- type MicrocosmSummaryRequestBySeq
- type MicrocosmSummaryType
- type MicrocosmType
- func (m *MicrocosmType) Delete() (int, error)
- func (m *MicrocosmType) Hydrate(siteID int64, profileID int64) (int, error)
- func (m *MicrocosmType) Import() (int, error)
- func (m *MicrocosmType) Insert() (int, error)
- func (m *MicrocosmType) Patch(ac AuthContext, patches []h.PatchType) (int, error)
- func (m *MicrocosmType) Update() (int, error)
- func (m *MicrocosmType) Validate(exists bool, isImport bool) (int, error)
- type MicrocosmsType
- type NewUser
- type OAuthClientType
- type PermissionType
- type PersonaRequestType
- type PersonaResponseType
- type PollChoiceType
- type PollSummaryType
- type PollType
- func (m *PollType) Delete() (int, error)
- func (m *PollType) Hydrate(siteID int64) (int, error)
- func (m *PollType) Insert(siteID int64, profileID int64) (int, error)
- func (m *PollType) Patch(ac AuthContext, patches []h.PatchType) (int, error)
- func (m *PollType) Update(siteID int64, profileID int64) (int, error)
- func (m *PollType) Validate(siteID int64, profileID int64, exists bool) (int, error)
- type PollsType
- type ProfileColumn
- type ProfileOptionType
- type ProfileSearchOptions
- type ProfileSummaryRequest
- type ProfileSummaryRequestBySeq
- type ProfileSummaryType
- func GetProfileSummary(siteID int64, id int64) (ProfileSummaryType, int, error)
- func GetProfiles(siteID int64, so ProfileSearchOptions, limit int64, offset int64) ([]ProfileSummaryType, int64, int64, int, error)
- func GetRoleMembers(siteID int64, roleID int64, limit int64, offset int64) ([]ProfileSummaryType, int64, int64, int, error)
- func GetRoleProfile(siteID int64, roleID int64, profileID int64) (ProfileSummaryType, int, error)
- func GetRoleProfiles(siteID int64, roleID int64, limit int64, offset int64) ([]ProfileSummaryType, int64, int64, int, error)
- type ProfileType
- func (m *ProfileType) Delete() (int, error)
- func (m *ProfileType) GetUnreadHuddleCount() (int, error)
- func (m *ProfileType) Import() (int, error)
- func (m *ProfileType) Insert() (int, error)
- func (m *ProfileType) Patch(ac AuthContext, patches []h.PatchType) (int, error)
- func (m *ProfileType) Update() (int, error)
- func (m *ProfileType) UpdateUnreadHuddleCount()
- func (m *ProfileType) Validate(exists bool) (int, error)
- type ProfilesType
- type ReadScopeType
- type ReadType
- type RequestDecoder
- type RewriteRule
- type RoleCriteriaType
- type RoleCriterionRequest
- type RoleCriterionRequestBySeq
- type RoleCriterionType
- func (m *RoleCriterionType) Delete(roleID int64) (int, error)
- func (m *RoleCriterionType) GetLink(roleLink string) string
- func (m *RoleCriterionType) Insert(roleID int64) (int, error)
- func (m *RoleCriterionType) Update(roleID int64) (int, error)
- func (m *RoleCriterionType) Validate(exists bool) (int, error)
- type RoleMetaType
- type RoleProfileType
- type RoleProfilesType
- type RoleSummaryType
- type RoleType
- func (m *RoleType) Delete() (int, error)
- func (m *RoleType) GetLink() string
- func (m *RoleType) Hydrate(siteID int64) (int, error)
- func (m *RoleType) Insert(siteID int64, profileID int64) (int, error)
- func (m *RoleType) Patch(ac AuthContext, patches []h.PatchType) (int, error)
- func (m *RoleType) Update(siteID int64, profileID int64) (int, error)
- func (m *RoleType) Validate(siteID int64, profileID int64, exists bool) (int, error)
- type RolesType
- type SearchQuery
- func (sq *SearchQuery) ParseBool(key string, value string, frag string)
- func (sq *SearchQuery) ParseDateTime(key string, value string, frag string)
- func (sq *SearchQuery) ParseFloat(key string, value string, frag string)
- func (sq *SearchQuery) ParseFullQueryString()
- func (sq *SearchQuery) ParseInt(key string, value string, frag string)
- func (sq *SearchQuery) ParseSingleQueryValue()
- func (sq *SearchQuery) Validate(siteID int64, profileID int64)
- type SearchResult
- type SearchResults
- type SiteHealthAttribute
- type SiteHealthType
- type SiteStatType
- type SiteType
- type SitesType
- type StandardResponse
- type SummaryContainer
- func GetAllItems(siteID int64, microcosmID int64, profileID int64, limit int64, offset int64) ([]SummaryContainer, int64, int64, int, error)
- func GetMostRecentItem(siteID int64, microcosmID int64, profileID int64) (SummaryContainer, int, error)
- func GetRootMicrocosm(siteID int64, profileID int64, limit int64, offset int64) ([]SummaryContainer, int64, int64, int, error)
- func GetSummaryContainer(siteID int64, itemTypeID int64, itemID int64, profileID int64) (SummaryContainer, int, error)
- type SummaryContainerRequest
- type SummaryContainerRequestsBySeq
- type ThreadedMetaType
- type TrendingItem
- type TrendingItems
- type UpdateDefaultOptionType
- type UpdateOptionType
- func GetCommunicationOptions(siteID int64, profileID int64, updateTypeID int64, itemTypeID int64, ...) (UpdateOptionType, int, error)
- func GetUpdateOptionByUpdateType(profileID int64, updateTypeID int64) (UpdateOptionType, int, error)
- func GetUpdateOptions(siteID int64, profileID int64) ([]UpdateOptionType, int, error)
- type UpdateRecipient
- type UpdateType
- type UpdateTypesType
- type UpdatesType
- type Usage
- type UserMembership
- type UserType
- type UsersType
- type WatcherType
- type WatchersType
Constants ¶
const ( // EventStatusProposed is for a proposed event EventStatusProposed string = "proposed" // EventStatusUpcoming is for a upcoming event EventStatusUpcoming string = "upcoming" // EventStatusPostponed is for a postponed event EventStatusPostponed string = "postponed" // EventStatusCancelled is for a cancelled event EventStatusCancelled string = "cancelled" // EventStatusPast is for a past event EventStatusPast string = "past" )
const ( // AvatarMaxWidth is the maximum width of an avatar AvatarMaxWidth int64 = 100 // AvatarMaxHeight is the maximum height of an avatar AvatarMaxHeight int64 = 100 // MaxFileSize is the maximum size (in bytes) of an attachment MaxFileSize int32 = 5242880 * 2 * 3 // 30MB // ImageGifMimeType is the mime type for GIF images ImageGifMimeType string = "image/gif" // ImageJpegMimeType is the mime type for JPG images ImageJpegMimeType string = "image/jpeg" // ImagePngMimeType is the mime type for PNG images ImagePngMimeType string = "image/png" // ImageSvgMimeType is the mime type for SVG images ImageSvgMimeType string = "image/svg+xml" )
const ( // Equals predicate Equals string = "eq" // NotEquals predicate NotEquals string = "ne" // LessThan predicate LessThan string = "lt" // LessThanOrEquals predicate LessThanOrEquals string = "le" // GreaterThanOrEquals predicate GreaterThanOrEquals string = "ge" // GreaterThan predicate GreaterThan string = "gt" // Substring predicate Substring string = "substr" // NotSubstring predicate NotSubstring string = "nsubstr" )
const ( // DefaultThemeID is hard-coded and matches the theme in the microweb // docroot DefaultThemeID int64 = 1 // DefaultBackgroundColor in hex DefaultBackgroundColor string = `#FFFFFF` // DefaultBackgroundPosition for any background CSS image DefaultBackgroundPosition string = `tile` // DefaultLinkColor in hex DefaultLinkColor string = `#4082C3` )
const URLGravatar string = "https://secure.gravatar.com/avatar/"
URLGravatar is the first part of the URL which Gravatar uses to serve avatars
const ( // URLProfile is the web interface URL to profiles URLProfile string = "/profiles/" )
const UserIDOffset int64 = 5830
UserIDOffset tracks an unfortunate byproduct of early sites being created and destroyed, in an effort to ensure that user names do not clash with other usernames
Variables ¶
var ( // StringPredicates handles the valid predicates for strings StringPredicates = []string{Equals, NotEquals, Substring, NotSubstring} // Int64Predicates handles the valid predicates for ints Int64Predicates = []string{ Equals, NotEquals, LessThan, LessThanOrEquals, GreaterThanOrEquals, GreaterThan, } // TimePredicates handles the valid predicates for ints TimePredicates = []string{ Equals, NotEquals, LessThan, LessThanOrEquals, GreaterThanOrEquals, GreaterThan, } // BoolPredicates handles the valid predicates for ints BoolPredicates = []string{Equals, NotEquals} // ProfileColumns is a hard-coded list of columns on the profiles table on // the database that we can filter against ProfileColumns = []ProfileColumn{ { Camel: "id", Snake: "profile_id", Type: "int64", Predicates: Int64Predicates, }, { Camel: "profileName", Snake: "profile_name", Type: "string", Predicates: StringPredicates, }, { Camel: "gender", Snake: "gender", Type: "string", Predicates: StringPredicates, }, { Camel: "email", Snake: "email", Type: "string", Predicates: StringPredicates, }, { Camel: "itemCount", Snake: "item_count", Type: "int64", Predicates: Int64Predicates, }, { Camel: "commentCount", Snake: "comment_count", Type: "int64", Predicates: Int64Predicates, }, { Camel: "created", Snake: "created", Type: "time", Predicates: TimePredicates, }, { Camel: "isBanned", Snake: "is_banned", Type: "bool", Predicates: BoolPredicates, }, } )
var ASCIISpace = rune(` `[0])
ASCIISpace ...
var AttributeTypes = map[string]int64{ // contains filtered or unexported fields }
AttributeTypes is a map of valid types of attributes
var DisallowedSubdomains = []string{
"about",
"abuse",
"account",
"accounts",
"admin",
"admins",
"adminstrator",
"adminstrators",
"api",
"assets",
"atom",
"billing",
"billings",
"blog",
"bugs",
"calendar",
"chat",
"code",
"communities",
"community",
"contact",
"contributors",
"coppa",
"copyright",
"css",
"customise",
"customize",
"demo",
"dev",
"developer",
"developers",
"development",
"direct",
"docs",
"email",
"example",
"feedback",
"files",
"forum",
"ftp",
"git",
"help",
"hostmaster",
"imap",
"inbox",
"jabber",
"lab",
"login",
"mail",
"manage",
"mobile",
"mx",
"official",
"owa",
"pages",
"payment",
"policy",
"pop",
"postmaster",
"press",
"privacy",
"prod",
"production",
"profile",
"search",
"secure",
"signup",
"sitemap",
"sites",
"smtp",
"ssl",
"staff",
"stage",
"staging",
"static",
"status",
"support",
"username",
"usernames",
"users",
"webmail",
"webmaster",
"www",
"xmpp",
}
DisallowedSubdomains is a list of all subdomains that cannot be registered
var RSVPStates = map[string]int64{
"yes": 1,
"maybe": 2,
"invited": 3,
"no": 4,
}
RSVPStates is a map of reply types, the numerical order is implicitly important (it's the sort field)
Functions ¶
func AnchorRelativeUrls ¶
AnchorRelativeUrls takes a HTML string that contains links like:
href="/profiles/"
and adds the given site's absolute URL so that it becomes:
href="https://key.microcosm.app/profiles/"
func CheckSiteResource ¶
CheckSiteResource is a utility for formatting site attribute URLs and determining whether they are reachable.
func CleanBlockText ¶
CleanBlockText allows everything, allows tabs, newlines, ASCII space but non-conforming whitespace, control chars, and also prevents shouting
func CleanSentence ¶
CleanSentence strips all HTML tags, allows ASCII space
func CreateOwnedSite ¶
CreateOwnedSite creates a new site and a profile to own the site, based on the user details provided.
func CreateRevisionLink ¶
CreateRevisionLink saves knowledge that this link appears in this revision
func DecrementItemCommentCount ¶
DecrementItemCommentCount is called when a comment is deleted from an item
func DecrementMicrocosmItemCount ¶
DecrementMicrocosmItemCount removes an item from the microcosm
func DecrementProfileCommentCount ¶
func DecrementProfileCommentCount(profileID int64)
DecrementProfileCommentCount decrements the comment count
func DeleteAttachment ¶
DeleteAttachment removes an attachment
func DeleteManyAttributes ¶
func DeleteManyAttributes( itemTypeID int64, itemID int64, ms []AttributeType, ) ( int, error, )
DeleteManyAttributes removes many attributes
func DeleteManyRoleCriteria ¶
func DeleteManyRoleCriteria(roleID int64, ems []RoleCriterionType) (int, error)
DeleteManyRoleCriteria deletes all matching criterion from the database
func DeleteManyRoleProfiles ¶
func DeleteManyRoleProfiles(roleID int64, ems []RoleProfileType) (int, error)
DeleteManyRoleProfiles removes many profiles from a role at once
func DeleteOldUpdates ¶
func DeleteOldUpdates()
DeleteOldUpdates purges old updates from the updates table
func DeleteOrphanedHuddles ¶
func DeleteOrphanedHuddles()
DeleteOrphanedHuddles finds huddles that no longer have participants and deletes them
func EmbedAllMedia ¶
EmbedAllMedia is called after a revision has been created to perform media embedding and gets all links in the revision and processes them all
func FetchProfileID ¶
FetchProfileID returns 0 if profile does not exist. Revision is used to ensure the profile exists on the same site as the revision
func FlushRoleMembersCacheByProfileID ¶
FlushRoleMembersCacheByProfileID clears the database caches
func FlushRoleMembersCacheByRoleID ¶
FlushRoleMembersCacheByRoleID clears the database caches
func FormatAsJSON ¶
FormatAsJSON sets the response headers to JSON and marshals the input as JSON
func ForumMetrics ¶
ForumMetrics builds metrics about sites
func GetAttendeeID ¶
GetAttendeeID returns the attendee id of a profile
func GetAttendeesCSV ¶
GetAttendeesCSV returns the attendees details as a CSV file
func GetAttributeID ¶
GetAttributeID fetches the id of an attribute
func GetComments ¶
func GetComments( siteID int64, itemType string, itemID int64, reqURL *url.URL, profileID int64, itemCreated time.Time, ) ( h.ArrayType, int, error, )
GetComments returns a collection of comments
func GetHuddleTitle ¶
GetHuddleTitle returns the title of the huddle
func GetItemCacheKeys ¶
GetItemCacheKeys is used by Items.go as everything else knows what it is Only need to handle commentable types that exist as child items in microcosms
func GetItems ¶
func GetItems( siteID int64, microcosmID int64, profileID int64, reqURL *url.URL, ) ( h.ArrayType, int, error, )
GetItems fetches items for a microcosm
func GetLastReadTime ¶
GetLastReadTime fetches the last time an item has been read by a profile
func GetLatestComments ¶
func GetLatestComments( siteID int64, itemType string, itemID int64, profileID int64, limit int64, ) ( int64, int64, int, error, )
GetLatestComments returns the latest comments for an item
func GetMicrocosmIDForItem ¶
GetMicrocosmIDForItem provides a cheap way to fetch an id for an item
func GetMicrocosmTitle ¶
GetMicrocosmTitle provides a cheap way to retrieve the title
func GetNextOrLastCommentID ¶
func GetNextOrLastCommentID( itemTypeID int64, itemID int64, timestamp time.Time, profileID int64, ) ( int64, int, error, )
GetNextOrLastCommentID returns the next or last comment identifier
func GetPageNumber ¶
func GetPageNumber( commentID int64, limit int64, profileID int64, ) ( int64, int64, int64, int, error, )
GetPageNumber returns the page of an item upon which a comment exists. This accounts for the viewer having ignored comments by others as well as comments marked as deleted.
func GetProfileEmail ¶
GetProfileEmail fetches the email address for a profile
func GetProfileID ¶
GetProfileID fetches a profileID given a userID
func GetRawCookiePolicyText ¶
func GetRawCookiePolicyText() string
GetRawCookiePolicyText returns the cookie policy
func GetRawPrivacyPolicyText ¶
func GetRawPrivacyPolicyText() string
GetRawPrivacyPolicyText returns the privacy policy
func GetRawTermsOfServiceText ¶
func GetRawTermsOfServiceText() string
GetRawTermsOfServiceText returns the terms of service
func GetRawTermsOfUseText ¶
func GetRawTermsOfUseText() string
GetRawTermsOfUseText returns the terms of use
func GetRequestIP ¶
GetRequestIP returns the IP address of the client making the request
func GetRootMicrocosmID ¶
GetRootMicrocosmID returns the ID of the microcosm that is the root microcosm that ultimately is the ancestor of all microcosms
func GetSiteStats ¶
GetSiteStats fetches and formats the statistics for a single site.
func GetSiteTitle ¶
GetSiteTitle returns (cheaply) the site title
func GetSummary ¶
func GetSummary( siteID int64, itemTypeID int64, itemID int64, profileID int64, ) ( interface{}, int, error, )
GetSummary fetches the smallest and most cacheable representation of a thing, usually the result of Get<Item>Summary
In this context, the 4th arg (profileId) is for the person asking for the summary That is needed for strongly permission items such as huddles.
func GetTitle ¶
func GetTitle( siteID int64, itemTypeID int64, itemID int64, profileID int64, ) ( string, int, error, )
GetTitle fetches a title of a thing, or something that can be used as a title. Will not trim or otherwise shorten the title. In the case of profile this returns the profileName, etc.
func GetWatcherAndIgnoreStatus ¶
func GetWatcherAndIgnoreStatus( itemTypeID int64, itemID int64, profileID int64, ) ( int64, bool, bool, bool, int, error, )
GetWatcherAndIgnoreStatus will return the communication preferences for a given item and profile
func HandleAttendeeRequest ¶
func HandleAttendeeRequest( siteID int64, id int64, seq int, out chan<- AttendeeRequest, )
HandleAttendeeRequest fetches an attendee for a request
func HandleAttributeRequest ¶
func HandleAttributeRequest(id int64, seq int, out chan<- AttributeRequest)
HandleAttributeRequest fetches an attribute to fulfil a request
func HandleCommentRequest ¶
func HandleCommentRequest( siteID int64, commentID int64, seq int, out chan<- CommentSummaryRequest, )
HandleCommentRequest fetches a comment given a request for one
func HandleMicrocosmSummaryRequest ¶
func HandleMicrocosmSummaryRequest( siteID int64, id int64, profileID int64, seq int, out chan<- MicrocosmSummaryRequest, )
HandleMicrocosmSummaryRequest provides a wrapper to fetching a summary
func HandleProfileSummaryRequest ¶
func HandleProfileSummaryRequest( siteID int64, id int64, seq int, out chan<- ProfileSummaryRequest, )
HandleProfileSummaryRequest is a wrapper to fetch a profile summary
func HandleRoleCriterionRequest ¶
func HandleRoleCriterionRequest( id int64, roleID int64, seq int, out chan<- RoleCriterionRequest, )
HandleRoleCriterionRequest wraps a request
func HandleSummaryContainerRequest ¶
func HandleSummaryContainerRequest( siteID int64, itemTypeID int64, itemID int64, profileID int64, seq int, out chan<- SummaryContainerRequest, )
HandleSummaryContainerRequest wraps GetSummaryContainer
func IncrementItemCommentCount ¶
IncrementItemCommentCount increments the comments of an item
func IncrementMicrocosmItemCount ¶
IncrementMicrocosmItemCount adds an item to the microcosm
func IncrementProfileCommentCount ¶
func IncrementProfileCommentCount(profileID int64)
IncrementProfileCommentCount increments the comment count
func IncrementViewCount ¶
IncrementViewCount increments the views of an item
func IsAttending ¶
IsAttending indicates whether the given profile is attending the event
func IsProfileNameTaken ¶
IsProfileNameTaken checks whether a profile name is taken for a given site, If the profile name is taken by the user specified then it's considered to be available (as in... updating your own profile won't fail this check) Errors in this method will return "true" for the check as data integrity is everything
func IsReservedSubdomain ¶
IsReservedSubdomain checks if a subdomain is reserved or used by an existing site.
func IsSpammer ¶
IsSpammer takes an email address and returns true if the email has ever been used to spam forums.
func MakeGravatarURL ¶
MakeGravatarURL hashes the email and creates the Gravatar URL
func ManageUsers ¶
func ManageUsers(site SiteType, ems []UserMembership) (int, error)
ManageUsers provides a way to ensure that a batch of users exists as profiles on a site (given their email address), and to grant/deny membership using the attribute key/values.
func MarkAllAsRead ¶
MarkAllAsRead marks everything on the site as read except huddles
func MarkAllHuddlesForAllProfilesAsReadOnSite ¶
MarkAllHuddlesForAllProfilesAsReadOnSite is used by the importer
func MarkAllMicrocosmsForAllProfilesAsReadOnSite ¶
MarkAllMicrocosmsForAllProfilesAsReadOnSite is used by the importer
func MarkAsRead ¶
func MarkAsRead( itemTypeID int64, itemID int64, profileID int64, updateTime time.Time, ) ( int, error, )
MarkAsRead will record when an item has been read by a profile
func MarkScopeAsRead ¶
func MarkScopeAsRead(profileID int64, rs ReadScopeType) (int, error)
MarkScopeAsRead will mark something like the site or a microcosm and all of it's contents as read
func MarkdownToHTML ¶
MarkdownToHTML wraps Black Friday and provides default settings for Black Friday
func MergeAndSendEmail ¶
func MergeAndSendEmail( siteID int64, from string, to string, subjectTemplate *template.Template, textTemplate *template.Template, htmlTemplate *template.Template, data interface{}, ) (int, error)
MergeAndSendEmail creates both parts of an email from database stored templates and then merges the metadata and sends them.
func ParseLinks ¶
ParseLinks will recursively walk the DOM and find the links
func PreProcessMentions ¶
PreProcessMentions will escape any characters in a username that markdown treats as special. This results in the username emerging from the markdown parser as it appears before this function is applied.
In other words: preserves usernames during the markdown process.
NOTE (buro9 2014-09-15): This unfortunately applies to <code> that is processed too, and results in text in code blocks being escaped, but not being unescaped by the Markdown processor... it is *not* aware of code blocks and is therefore buggy.
func ProcessBBCode ¶
ProcessBBCode replaces BBCode with Markdown
func ProcessCommentMarkdown ¶
func ProcessCommentMarkdown( tx *sql.Tx, revisionID int64, markdown string, siteID int64, itemTypeID int64, itemID int64, sendUpdates bool, ) ( string, error, )
ProcessCommentMarkdown will turn the latest revision markdown into HTML
func ProcessHashtags ¶
ProcessHashtags finds hashtags within some markdown and turns them into markdown hyperlinks
func ProcessLinks ¶
ProcessLinks will fetch the HTML for a revision and extract and shorten all hyperlinks
func ProcessMention ¶
func ProcessMention( tx *sql.Tx, commentID int64, revisionID int64, createdBy int64, profileID int64, siteID int64, itemTypeID int64, itemID int64, sendUpdates bool, ) error
ProcessMention processes username mentions using the `+username` syntax and generates alerts for the mentioned user if they have are enabled in their preferences.
func ProcessMentions ¶
func ProcessMentions( tx *sql.Tx, revisionID int64, src []byte, siteID int64, itemTypeID int64, itemID int64, sendUpdates bool, ) ( []byte, error, )
ProcessMentions will find + and @ mentions in a revision and linkify them whilst also notifying the people mentioned (if applicable)
func ProfileMetrics ¶
ProfileMetrics builds metrics about profiles
func PurgeCache ¶
PurgeCache removes an item from the cache
func PurgeCacheByScope ¶
PurgeCacheByScope removes part of an item from the cache
func RegisterWatcher ¶
func RegisterWatcher( profileID int64, updateTypeID int64, itemID int64, itemTypeID int64, siteID int64, ) ( bool, int, error, )
RegisterWatcher is offers an idempotent operation for creating a watcher on a specific item
func SanitiseHTML ¶
SanitiseHTML sanitizes HTML Leaving a safe set of HTML intact that is not going to pose an XSS risk
func SendUpdatesForEventReminder ¶
SendUpdatesForEventReminder is Update Type #7 : Event reminder as event imminent
func SendUpdatesForNewAttendeeInAnEvent ¶
func SendUpdatesForNewAttendeeInAnEvent( siteID int64, attendee AttendeeType, ) ( int, error, )
SendUpdatesForNewAttendeeInAnEvent is Update Type #5 : New attendee in an event
func SendUpdatesForNewCommentInHuddle ¶
func SendUpdatesForNewCommentInHuddle( siteID int64, comment CommentSummaryType, ) ( int, error, )
SendUpdatesForNewCommentInHuddle is Update Type #4 : New comment in a huddle you are participating in
TODO(buro9): This is still based on the same code as new comment, but are there some special rules because it's a huddle? If so, they're not yet implemented.
func SendUpdatesForNewCommentInItem ¶
func SendUpdatesForNewCommentInItem( siteID int64, comment CommentSummaryType, ) ( int, error, )
SendUpdatesForNewCommentInItem is Update Type #1 : New comment in an item you're watching
func SendUpdatesForNewItemInAMicrocosm ¶
SendUpdatesForNewItemInAMicrocosm is Update Type #8 : A new item in a Microcosm
func SendUpdatesForNewMentionInComment ¶
func SendUpdatesForNewMentionInComment( siteID int64, forProfileID int64, commentID int64, ) ( int, error, )
SendUpdatesForNewMentionInComment is Update Type #3 : New mention in a comment
func SendUpdatesForNewReplyToYourComment ¶
func SendUpdatesForNewReplyToYourComment( siteID int64, comment CommentSummaryType, ) ( int, error, )
SendUpdatesForNewReplyToYourComment is Update Type #2 : New reply to a comment that you made
func SendUpdatesForNewUserOnSite ¶
func SendUpdatesForNewUserOnSite( site SiteType, profile ProfileType, user UserType, ) ( int, error, )
SendUpdatesForNewUserOnSite is Update Type #9 : A new user on a site
func SendUpdatesForNewVoteInAPoll ¶
SendUpdatesForNewVoteInAPoll is Update Type #6 : New vote in a poll
func SendUsage ¶
func SendUsage( c *Context, statusCode int, contentLength int, dur time.Duration, errors []string, )
SendUsage is called at the end of processing a request and will record info about the request for analytics and error detection later
func SetCommentInReplyTo ¶
SetCommentInReplyTo updates the in_reply_to value of a comment. This is only for imports as it is never anticipated that this value will change once it has been set.
func ShortenLink ¶
func ShortenLink( revisionID int64, fullURL string, host string, site SiteType, text string, links *[]Link, ) ( string, string, string, error, )
ShortenLink shortens a single link
func SuggestProfileName ¶
SuggestProfileName will create a semi-random username for a new user
func UnmarshalForm ¶
UnmarshalForm fills a struct `v` from the values in `form`
func UpdateAllSiteStats ¶
func UpdateAllSiteStats()
UpdateAllSiteStats updates the site stats across all sites
func UpdateCommentCountForAllProfiles ¶
UpdateCommentCountForAllProfiles is intended as an import/admin task only. It is relatively expensive due to calling is_deleted() for every comment on a site.
func UpdateEmbedsForDomain ¶
UpdateEmbedsForDomain is used when we have new media definitions (i.e. for YouTube)
func UpdateLastActive ¶
UpdateLastActive marks a profile as being active
func UpdateManyAttendees ¶
func UpdateManyAttendees(siteID int64, ems []AttendeeType) (int, error)
UpdateManyAttendees updates many attendees
func UpdateManyAttributes ¶
func UpdateManyAttributes( itemTypeID int64, itemID int64, ems []AttributeType, ) ( int, error, )
UpdateManyAttributes updates many attributes at once
func UpdateManyHuddleParticipants ¶
func UpdateManyHuddleParticipants( siteID int64, huddleID int64, ems []HuddleParticipantType, ) ( int, error, )
UpdateManyHuddleParticipants saves many participants
func UpdateManyRoleProfiles ¶
func UpdateManyRoleProfiles( siteID int64, roleID int64, ems []RoleProfileType, ) ( int, error, )
UpdateManyRoleProfiles allows many role profiles to be added at the same time
func UpdateMenu ¶
UpdateMenu saves the full menu
func UpdateMetricsCron ¶
func UpdateMetricsCron()
UpdateMetricsCron updates the metrics used by the internal dashboard by the admins. This includes counts of the number of items, changes in active sites, etc.
func UpdateMicrocosmItemCounts ¶
func UpdateMicrocosmItemCounts()
UpdateMicrocosmItemCounts updates the count of items for microcosms, which is used to order the microcosms
This is pure housekeeping, the numbers are maintained through increments and decrements as stuff is added and deleted, but there are edge cases that may result in the numbers not being accurate (batch deletions, things being deleted via PATCH, etc).
This function is designed to calculate the real numbers and only update rows where the numbers are not the real numbers.
func UpdateProfileCounts ¶
func UpdateProfileCounts()
UpdateProfileCounts updates the count of profiles per site
func UpdateSiteStats ¶
UpdateSiteStats updates the stats for a given site
func UpdateUnreadHuddleCount ¶
func UpdateUnreadHuddleCount(profileID int64)
UpdateUnreadHuddleCount updates the unread huddle count
func UpdateViewCounts ¶
func UpdateViewCounts()
UpdateViewCounts reads from the views table and will SUM the number of views and update all of the associated conversations and events with the new view count.
func UpdateWhosOnline ¶
func UpdateWhosOnline()
UpdateWhosOnline updates the site_stats with the current number of people online on a site
func UserGenMetrics ¶
UserGenMetrics builds metrics about user activity
func UserIsOnSite ¶
UserIsOnSite returns true if the given userId exists as a profile on the given site.
Types ¶
type AccessTokenRequestType ¶
AccessTokenRequestType is a request for an access token
type AccessTokenType ¶
type AccessTokenType struct { AccessTokenID int64 `json:"-"` TokenValue string `json:"accessToken"` UserID int64 `json:"-"` User UserType `json:"user"` ClientID int64 `json:"clientId"` Created time.Time `json:"created"` Expires time.Time `json:"expires"` }
AccessTokenType describes an access token
func GetAccessToken ¶
func GetAccessToken(token string) (AccessTokenType, int, error)
GetAccessToken returns an access token
func (*AccessTokenType) Delete ¶
func (m *AccessTokenType) Delete() (int, error)
Delete removes an access token
func (*AccessTokenType) Insert ¶
func (m *AccessTokenType) Insert() (int, error)
Insert saves an access token
type AttachmentType ¶
type AttachmentType struct { AttachmentID int64 `json:"-"` ProfileID int64 `json:"profileId"` AttachmentMetaID int64 `json:"-"` ItemTypeID int64 `json:"-"` FileHash string `json:"fileHash"` FileName string `json:"fileName"` FileExt string `json:"fileExt"` ItemID int64 `json:"-"` Created time.Time `json:"created"` ViewCount int64 `json:"-"` Meta h.CoreMetaType `json:"meta"` }
AttachmentType describes an attachment
func AttachAvatar ¶
func AttachAvatar( profileID int64, fileMetadata FileMetadataType, ) ( AttachmentType, int, error, )
AttachAvatar allows file uploading of a custom avatar
func GetAttachment ¶
func GetAttachment( itemTypeID int64, itemID int64, fileHash string, latest bool, ) ( AttachmentType, int, error, )
GetAttachment returns an attachment
func GetAttachments ¶
func GetAttachments( itemTypeID int64, itemID int64, limit int64, offset int64, ) ( []AttachmentType, int64, int64, int, error, )
GetAttachments returns a collection of attachments
func (*AttachmentType) Import ¶
func (m *AttachmentType) Import() (int, error)
Import saves an attachment
func (*AttachmentType) Insert ¶
func (m *AttachmentType) Insert() (int, error)
Insert saves an attachment
func (*AttachmentType) Update ¶
func (m *AttachmentType) Update() (int, error)
Update saves the changes to an attachment
type AttachmentsType ¶
type AttachmentsType struct { Attachments h.ArrayType `json:"attachments"` Meta h.CoreMetaType `json:"meta"` }
AttachmentsType is a collection of attachments
type AttendeeRequest ¶
type AttendeeRequest struct { Item AttendeeType Err error Status int Seq int }
AttendeeRequest is a request for an attendee
type AttendeeRequestBySeq ¶
type AttendeeRequestBySeq []AttendeeRequest
AttendeeRequestBySeq is a collection of requests for attendees
func (AttendeeRequestBySeq) Len ¶
func (v AttendeeRequestBySeq) Len() int
Len is the length of the collection
func (AttendeeRequestBySeq) Less ¶
func (v AttendeeRequestBySeq) Less(i, j int) bool
Less determines if an item is less then another by sequence
func (AttendeeRequestBySeq) Swap ¶
func (v AttendeeRequestBySeq) Swap(i, j int)
Swap exchanges two items in the collection
type AttendeeType ¶
type AttendeeType struct { ID int64 `json:"-"` EventID int64 `json:"-"` ProfileID int64 `json:"profileId,omitempty"` Profile interface{} `json:"profile"` RSVPID int64 `json:"-"` RSVP string `json:"rsvp"` RSVPd pq.NullTime `json:"-"` RSVPdOn string `json:"rsvpdOn,omitempty"` Meta h.DefaultNoFlagsMetaType `json:"meta"` }
AttendeeType is an attendee on an event
func GetAttendee ¶
func GetAttendee(siteID int64, id int64) (AttendeeType, int, error)
GetAttendee returns an attendee
func GetAttendees ¶
func GetAttendees( siteID int64, eventID int64, limit int64, offset int64, attending bool, ) ( []AttendeeType, int64, int64, int, error, )
GetAttendees returns a collection of attendees
func (*AttendeeType) Delete ¶
func (m *AttendeeType) Delete(siteID int64) (int, error)
Delete removes an attendee
func (*AttendeeType) Hydrate ¶
func (m *AttendeeType) Hydrate(siteID int64) (int, error)
Hydrate populates a partially populated struct
type AttendeesType ¶
type AttendeesType struct { Attendees h.ArrayType `json:"attendees"` Meta h.CoreMetaType `json:"meta"` }
AttendeesType is a collection of attendees
type AttributeRequest ¶
type AttributeRequest struct { Item AttributeType Err error Status int Seq int }
AttributeRequest is a wrapper for a request for an attribute
type AttributeRequestBySeq ¶
type AttributeRequestBySeq []AttributeRequest
AttributeRequestBySeq is a collection of attribute requests
func (AttributeRequestBySeq) Len ¶
func (v AttributeRequestBySeq) Len() int
Len is the length of the collection
func (AttributeRequestBySeq) Less ¶
func (v AttributeRequestBySeq) Less(i, j int) bool
Less determines if an attribute is less by sequence than another
func (AttributeRequestBySeq) Swap ¶
func (v AttributeRequestBySeq) Swap(i, j int)
Swap exchanges two items in the collection
type AttributeType ¶
type AttributeType struct { ID int64 `json:"-"` Key string `json:"key"` Type string `json:"-"` Value interface{} `json:"value"` String sql.NullString `json:"-"` Number sql.NullFloat64 `json:"-"` Date pq.NullTime `json:"-"` Boolean sql.NullBool `json:"-"` }
AttributeType is an attribute
func GetAttribute ¶
func GetAttribute(id int64) (AttributeType, int, error)
GetAttribute returns an attribute
func GetAttributes ¶
func GetAttributes( itemTypeID int64, itemID int64, limit int64, offset int64, ) ( []AttributeType, int64, int64, int, error, )
GetAttributes fetches a collection of attributes
func (*AttributeType) Delete ¶
func (m *AttributeType) Delete() (int, error)
Delete removes a single attribute
func (*AttributeType) Update ¶
func (m *AttributeType) Update(itemTypeID int64, itemID int64) (int, error)
Update updates a single attribute
func (*AttributeType) Validate ¶
func (m *AttributeType) Validate() (int, error)
Validate returns true if the attribute is valid
type AttributesType ¶
AttributesType is a collection of attributes
type AuthContext ¶
type AuthContext struct { SiteID int64 ProfileID int64 IsSiteOwner bool MicrocosmID int64 ItemTypeID int64 ItemID int64 }
AuthContext describes the context for which authorisation is sought
func MakeAuthorisationContext ¶
func MakeAuthorisationContext( c *Context, m int64, t int64, i int64, ) AuthContext
MakeAuthorisationContext creates an auth context from a request context
type AuthType ¶
type AuthType struct { UserID int64 ProfileID int64 IsSiteOwner bool IsBanned bool Method string AccessToken AccessTokenType }
AuthType describes the auth knowledge of the current request
type CommentFlagsMetaType ¶
type CommentFlagsMetaType struct {
ThreadedMetaType
}
CommentFlagsMetaType is a flags meta struct for comments
type CommentFlagsType ¶
type CommentFlagsType struct { Deleted bool `json:"deleted"` Moderated bool `json:"moderated"` Visible bool `json:"visible"` Unread bool `json:"unread"` }
CommentFlagsType is the flags meta struct of a comment
type CommentMetaType ¶
type CommentMetaType struct { h.CreatedType h.EditedType Flags CommentFlagsType `json:"flags,omitempty"` h.CoreMetaType }
CommentMetaType is the meta struct of a comment
type CommentRequestBySeq ¶
type CommentRequestBySeq []CommentSummaryRequest
CommentRequestBySeq is a collection of comment summary requests
func (CommentRequestBySeq) Len ¶
func (v CommentRequestBySeq) Len() int
Len is the length of the comment requests
func (CommentRequestBySeq) Less ¶
func (v CommentRequestBySeq) Less(i, j int) bool
Less determines which of the two items is less by sequence
func (CommentRequestBySeq) Swap ¶
func (v CommentRequestBySeq) Swap(i, j int)
Swap exchanges two items in the collection
type CommentSummaryRequest ¶
type CommentSummaryRequest struct { Item CommentSummaryType Err error Status int Seq int }
CommentSummaryRequest is an envelope for a comment summary request
type CommentSummaryType ¶
type CommentSummaryType struct { ID int64 `json:"id"` ItemTypeID int64 `json:"-"` ItemType string `json:"itemType"` ItemID int64 `json:"itemId"` Revisions int64 `json:"revisions"` InReplyToNullable sql.NullInt64 `json:"-"` InReplyTo int64 `json:"inReplyTo,omitempty"` Attachments int64 `json:"attachments,omitempty"` FirstLine string `json:"firstLine,omitempty"` Markdown string `json:"markdown"` HTMLNullable sql.NullString `json:"-"` HTML string `json:"html"` Files []h.AttachmentType `json:"files,omitempty"` Meta CommentMetaType `json:"meta"` }
CommentSummaryType is a summary of a comment
func GetCommentSummary ¶
func GetCommentSummary( siteID int64, commentID int64, ) ( CommentSummaryType, int, error, )
GetCommentSummary returns a comment
func GetItemComments ¶
func GetItemComments( siteID int64, itemType string, itemID int64, limit int64, offset int64, profileID int64, itemCreated time.Time, ) ( []CommentSummaryType, int64, int64, int, error, )
GetItemComments fetches a page of comments on an item
func (*CommentSummaryType) CreateCommentRevision ¶
func (m *CommentSummaryType) CreateCommentRevision( tx *sql.Tx, isFirst bool, siteID int64, itemTypeID int64, itemID int64, isImport bool, ) ( int64, int, error, )
CreateCommentRevision saves a version of the comment text
func (*CommentSummaryType) Delete ¶
func (m *CommentSummaryType) Delete(siteID int64) (int, error)
Delete removes a comment
func (*CommentSummaryType) GetPageLink ¶
func (m *CommentSummaryType) GetPageLink( limit int64, profileID int64, ) ( h.LinkType, int, error, )
GetPageLink returns a link to a page for a comment
func (*CommentSummaryType) Hydrate ¶
func (m *CommentSummaryType) Hydrate(siteID int64) (int, error)
Hydrate populates a partially populated struct
func (*CommentSummaryType) Import ¶
func (m *CommentSummaryType) Import(siteID int64) (int, error)
Import saves a cumment without performing a dupe check
func (*CommentSummaryType) Insert ¶
func (m *CommentSummaryType) Insert(siteID int64) (int, error)
Insert saves a comment
func (*CommentSummaryType) Patch ¶
func (m *CommentSummaryType) Patch( siteID int64, ac AuthContext, patches []h.PatchType, ) ( int, error, )
Patch saves a partially updated comment
type CommentType ¶
type CommentType struct { ID int64 `json:"id"` ItemTypeID int64 `json:"-"` ItemType string `json:"itemType"` ItemID int64 `json:"itemId"` Revisions int64 `json:"revisions"` InReplyToNullable sql.NullInt64 `json:"-"` InReplyTo int64 `json:"inReplyTo"` Attachments int64 `json:"attachments"` FirstLine string `json:"firstLine"` Markdown string `json:"markdown"` HTMLNullable sql.NullString `json:"-"` HTML string `json:"html"` Files []h.AttachmentType `json:"files,omitempty"` Meta CommentFlagsMetaType `json:"meta"` }
CommentType encapsulates a comment
func GetComment ¶
func GetComment( siteID int64, commentID int64, profileID int64, limit int64, ) ( CommentType, int, error, )
GetComment fetches a comment
type CommentsType ¶
type CommentsType struct { Comments h.ArrayType `json:"comments"` Meta h.CoreMetaType `json:"meta"` }
CommentsType is a collection of comments
type Context ¶
type Context struct { Request *http.Request ResponseWriter http.ResponseWriter Site SiteType Auth AuthType RouteVars map[string]string StartTime time.Time IP net.IP }
Context is a web request and auth context wrapper
func MakeContext ¶
func MakeContext( request *http.Request, responseWriter http.ResponseWriter, ) ( *Context, int, error, )
MakeContext creates a Context for the current request
func MakeEmptyContext ¶
func MakeEmptyContext( request *http.Request, responseWriter http.ResponseWriter, ) ( *Context, int, error, )
MakeEmptyContext makes an empty Context for anonymous responses
func (*Context) Fill ¶
Fill is a context.Context Helper function to fill a variable with the contents of the request body. The body will be decoded based on the content-type and an apropriate RequestDecoder automatically selected
func (*Context) GetHTTPMethod ¶
GetHTTPMethod returns the HTTP method, accounting for method overriding
func (*Context) GetItemTypeAndItemID ¶
GetItemTypeAndItemID extracts the item type and ID from the request
func (*Context) IsRootSite ¶
IsRootSite returns true if this is the root site
func (*Context) Respond ¶
func (c *Context) Respond( data interface{}, statusCode int, errors []string, context *Context, ) error
Respond prepares a response
func (*Context) RespondWithData ¶
RespondWithData responds with the specified data
func (*Context) RespondWithError ¶
RespondWithError responds with the specified HTTP status code defined in RFC2616 and adds the status description to the errors list see http://golang.org/src/pkg/http/status.go for options
func (*Context) RespondWithErrorDetail ¶
RespondWithErrorDetail responds with detailed error code and message in the data object.
func (*Context) RespondWithErrorMessage ¶
RespondWithErrorMessage responds with custom code and an error message
func (*Context) RespondWithLocation ¶
RespondWithLocation responds with 307 Temporarily Moved (temp redirect)
func (*Context) RespondWithMoved ¶
RespondWithMoved responds with 301 Permanently Moved (perm redirect)
func (*Context) RespondWithNotFound ¶
RespondWithNotFound responds with 404 Not Found
func (*Context) RespondWithNotImplemented ¶
RespondWithNotImplemented responds with 501 Not Implemented
func (*Context) RespondWithOK ¶
RespondWithOK responds with OK status (200) and no data
func (*Context) RespondWithOptions ¶
RespondWithOptions returns OPTIONS
func (*Context) RespondWithSeeOther ¶
RespondWithSeeOther responds with 303 See Other (created redirect)
func (*Context) RespondWithStatus ¶
RespondWithStatus responds with a custom status code and an empty StandardResponse struct
type ConversationSummaryType ¶
type ConversationSummaryType struct { ItemSummary ItemSummaryMeta }
ConversationSummaryType is a summary of a conversation
func GetConversationSummary ¶
func GetConversationSummary( siteID int64, id int64, profileID int64, ) ( ConversationSummaryType, int, error, )
GetConversationSummary fetches a summary of a conversation
type ConversationType ¶
type ConversationType struct { ItemDetail ItemDetailCommentsAndMeta }
ConversationType is a conversation
func GetConversation ¶
GetConversation fetches a conversation
func (*ConversationType) Delete ¶
func (m *ConversationType) Delete() (int, error)
Delete deletes a conversation
func (*ConversationType) Hydrate ¶
func (m *ConversationType) Hydrate(siteID int64) (int, error)
Hydrate populates a partially populated struct
func (*ConversationType) Import ¶
func (m *ConversationType) Import(siteID int64, profileID int64) (int, error)
Import saves a conversation with duplicate checking
func (*ConversationType) Insert ¶
func (m *ConversationType) Insert(siteID int64, profileID int64) (int, error)
Insert saves a conversation
func (*ConversationType) Patch ¶
func (m *ConversationType) Patch( ac AuthContext, patches []h.PatchType, ) ( int, error, )
Patch partially updates a saved conversation
type ConversationsType ¶
type ConversationsType struct { Conversations h.ArrayType `json:"conversations"` Meta h.CoreMetaType `json:"meta"` }
ConversationsType is a collection of conversations
type EmailMergeData ¶
type EmailMergeData struct { SiteTitle string ProtoAndHost string ForProfile ProfileSummaryType ForEmail string ByProfile ProfileSummaryType Subject string ContextLink string ContextText string Body string Site SiteType NewUser NewUser }
EmailMergeData encapsulates the merge object that will be used by the template merge to make values available to the template
type EmailType ¶
type EmailType struct { From string ReplyTo string To string Subject string BodyText string BodyHTML string }
EmailType describes an email
type EventSummaryType ¶
type EventSummaryType struct { ItemSummary // Specific to events WhenNullable pq.NullTime `json:"-"` When string `json:"when,omitempty"` TZ string `json:"tz,omitempty"` WhenTzNullable pq.NullTime `json:"-"` WhenTz string `json:"whentz,omitempty"` Duration int64 `json:"duration,omitempty"` WhereNullable sql.NullString `json:"-"` Where string `json:"where,omitempty"` Lat float64 `json:"lat,omitempty"` Lon float64 `json:"lon,omitempty"` North float64 `json:"north,omitempty"` East float64 `json:"east,omitempty"` South float64 `json:"south,omitempty"` West float64 `json:"west,omitempty"` Status string `json:"status"` RSVPLimit int32 `json:"rsvpLimit"` RSVPAttending int32 `json:"rsvpAttend,omitempty"` RSVPSpaces int32 `json:"rsvpSpaces,omitempty"` ItemSummaryMeta }
EventSummaryType is a summary of an event
func GetEventSummary ¶
GetEventSummary returns a summary of an event
func GetEvents ¶
func GetEvents( siteID int64, profileID int64, attending bool, limit int64, offset int64, ) ( []EventSummaryType, int64, int64, int, error, )
GetEvents returns a collection of events
func (*EventSummaryType) GetAttending ¶
func (m *EventSummaryType) GetAttending(profileID int64) (int, error)
GetAttending populates the attending list of an event summary
type EventType ¶
type EventType struct { ItemDetail // Specific to events WhenNullable pq.NullTime `json:"-"` When string `json:"when,omitempty"` TZ string `json:"tz,omitempty"` WhenTzNullable pq.NullTime `json:"-"` WhenTz string `json:"whentz,omitempty"` Duration int32 `json:"duration,omitempty"` Where string `json:"where,omitempty"` WhereNullable sql.NullString `json:"-"` Lat float64 `json:"lat,omitempty"` Lon float64 `json:"lon,omitempty"` North float64 `json:"north,omitempty"` East float64 `json:"east,omitempty"` South float64 `json:"south,omitempty"` West float64 `json:"west,omitempty"` Status string `json:"status"` RSVPLimit int32 `json:"rsvpLimit"` RSVPAttending int32 `json:"rsvpAttend,omitempty"` RSVPSpaces int32 `json:"rsvpSpaces,omitempty"` ItemDetailCommentsAndMeta }
EventType is an event
func (*EventType) GetAttending ¶
GetAttending populates the attending list of an event
func (*EventType) UpdateAttendees ¶
UpdateAttendees updates the number of attendees for an event
type EventsType ¶
type EventsType struct { Events h.ArrayType `json:"events"` Meta h.CoreMetaType `json:"meta"` }
EventsType is a collection of events
type FileMetadataType ¶
type FileMetadataType struct { AttachmentMetaID int64 `json:"-"` Created time.Time `json:"created"` FileName string `json:"fileName"` FileExt string `json:"fileExt"` FileSize int32 `json:"fileSize"` FileHash string `json:"fileHash"` MimeType string `json:"mimeType"` WidthNullable sql.NullInt64 `json:"-"` Width int64 `json:"width,omitempty"` HeightNullable sql.NullInt64 `json:"-"` Height int64 `json:"height,omitempty"` ThumbnailWidthNullable sql.NullInt64 `json:"-"` ThumbnailWidth int64 `json:"thumbnailHeight,omitempty"` ThumbnailHeightNullable sql.NullInt64 `json:"-"` ThumbnailHeight int64 `json:"thumbnailWidth,omitempty"` AttachCount int64 `json:"-"` Content []byte `json:"-"` }
FileMetadataType represents the 'attachment_meta' table
func GetMetadata ¶
func GetMetadata(fileHash string) (FileMetadataType, int, error)
GetMetadata returns a file's metadata by it's hash
func StoreGravatar ¶
func StoreGravatar(gravatarURL string) (FileMetadataType, int, error)
StoreGravatar stores the gravatar file in the database
func (*FileMetadataType) Import ¶
func (f *FileMetadataType) Import( maxWidth int64, maxHeight int64, ) ( int, error, )
Import saves a file metadata to the database without validating it
func (*FileMetadataType) Insert ¶
func (f *FileMetadataType) Insert( maxWidth int64, maxHeight int64, ) ( int, error, )
Insert saves a file metadata to the database
func (*FileMetadataType) ResizeImage ¶
func (f *FileMetadataType) ResizeImage( maxWidth int64, maxHeight int64, ) ( int, error, )
ResizeImage will resize an image (usually an avatar) to fit within the given constraints whilst preserving the aspect ratio
func (*FileMetadataType) Update ¶
func (f *FileMetadataType) Update() (int, error)
Update saves changes to to a file
func (*FileMetadataType) Validate ¶
func (f *FileMetadataType) Validate() (int, error)
Validate returns true of the file metadata is valid
type FormRequestDecoder ¶
type FormRequestDecoder struct{}
FormRequestDecoder is a form-enc decoder for request body
func (*FormRequestDecoder) Unmarshal ¶
func (d *FormRequestDecoder) Unmarshal(cx *Context, v interface{}) error
Unmarshal decodes a HTTP form
type HuddleParticipantType ¶
type HuddleParticipantType struct { ID int64 `json:"id,omitempty"` Profile interface{} `json:"participant"` }
HuddleParticipantType describes a person who is able to view and interact with a huddle
func GetHuddleParticipant ¶
func GetHuddleParticipant( siteID int64, huddleID int64, profileID int64, ) ( HuddleParticipantType, int, error, )
GetHuddleParticipant fetches a huddle participant
func GetHuddleParticipants ¶
func GetHuddleParticipants( siteID int64, huddleID int64, limit int64, offset int64, ) ( []HuddleParticipantType, int64, int64, int, error, )
GetHuddleParticipants returns a collection of huddle participants
func (*HuddleParticipantType) Delete ¶
func (m *HuddleParticipantType) Delete(huddleID int64) (int, error)
Delete removes a participant from a huddle
func (*HuddleParticipantType) GetLink ¶
func (m *HuddleParticipantType) GetLink(link string) string
GetLink returns the API link to a participant
type HuddleParticipantsType ¶
type HuddleParticipantsType struct { HuddleParticipants h.ArrayType `json:"participants"` Meta h.CoreMetaType `json:"meta"` }
HuddleParticipantsType is a collection of huddle participants
type HuddleSummaryType ¶
type HuddleSummaryType struct { ID int64 `json:"id"` SiteID int64 `json:"siteId,omitempty"` Title string `json:"title"` CommentCount int64 `json:"totalComments"` Participants []ProfileSummaryType `json:"participants"` LastCommentIDNullable sql.NullInt64 `json:"-"` LastCommentID int64 `json:"lastCommentId,omitempty"` LastCommentCreatedByNullable sql.NullInt64 `json:"-"` LastCommentCreatedBy interface{} `json:"lastCommentCreatedBy,omitempty"` LastCommentCreatedNullable pq.NullTime `json:"-"` LastCommentCreated string `json:"lastCommentCreated,omitempty"` Meta h.SummaryMetaType `json:"meta"` }
HuddleSummaryType is a summary of a huddle
func GetHuddleSummary ¶
func GetHuddleSummary( siteID int64, profileID int64, id int64, ) ( HuddleSummaryType, int, error, )
GetHuddleSummary returns a summary of a huddle
type HuddleType ¶
type HuddleType struct { ID int64 `json:"id"` SiteID int64 `json:"siteId,omitempty"` Title string `json:"title"` IsConfidential bool `json:"isConfidential"` Participants []ProfileSummaryType `json:"participants"` Comments h.ArrayType `json:"comments"` Meta h.SummaryMetaType `json:"meta"` }
HuddleType is a huddle
func (*HuddleType) Delete ¶
func (m *HuddleType) Delete(siteID int64, profileID int64) (int, error)
Delete removes a participant from a huddle
func (*HuddleType) GetLink ¶
func (m *HuddleType) GetLink() string
GetLink returns the link to this huddle
func (*HuddleType) Hydrate ¶
func (m *HuddleType) Hydrate(siteID int64) (int, error)
Hydrate populates the partially populated huddle
func (*HuddleType) Import ¶
func (m *HuddleType) Import(siteID int64) (int, error)
Import allows a huddle to be added without performing dupe checks
type HuddlesType ¶
type HuddlesType struct { Huddles h.ArrayType `json:"huddles"` Meta h.CoreMetaType `json:"meta"` }
HuddlesType is a collection of huddles
type IgnoreType ¶
type IgnoreType struct { ProfileID int64 `json:"-"` ItemTypeID int64 `json:"-"` ItemType string `json:"itemType,omitempty"` ItemID int64 `json:"itemId,omitempty"` Item interface{} `json:"item,omitempty"` }
IgnoreType is an ignored item
func GetIgnored ¶
func GetIgnored( siteID int64, profileID int64, limit int64, offset int64, ) ( []IgnoreType, int64, int64, int, error, )
GetIgnored returns a collection of ignored items
func (*IgnoreType) Update ¶
func (m *IgnoreType) Update() (int, error)
Update saves the ignore to the database
func (*IgnoreType) Validate ¶
func (m *IgnoreType) Validate() (int, error)
Validate returns true if the item is valid
type IgnoredType ¶
type IgnoredType struct { Ignored h.ArrayType `json:"ignored"` Meta h.CoreMetaType `json:"meta"` }
IgnoredType is a collection of ignored items
type Item ¶
type Item struct { ItemParent ItemTypeID int64 `json:"-"` ItemType string `json:"itemType"` ID int64 `json:"id"` Title string `json:"title"` CommentCount int64 `json:"totalComments"` ViewCount int64 `json:"totalViews"` LastCommentIDNullable sql.NullInt64 `json:"-"` LastCommentID int64 `json:"lastCommentId,omitempty"` LastCommentCreatedByNullable sql.NullInt64 `json:"-"` LastCommentCreatedBy interface{} `json:"lastCommentCreatedBy,omitempty"` LastCommentCreatedNullable pq.NullTime `json:"-"` LastCommentCreated string `json:"lastCommentCreated,omitempty"` Meta h.DefaultMetaType `json:"meta"` }
Item is a set of minimal and common fields used by items that exist on the site, usually things that exist within a microcosm
type ItemDetail ¶
type ItemDetail struct { // Common Fields ID int64 `json:"id"` Title string `json:"title"` ItemParent // Used during import to set the view count ViewCount int64 `json:"-"` }
ItemDetail describes an item and the microcosm it belongs to
type ItemDetailCommentsAndMeta ¶
type ItemDetailCommentsAndMeta struct { // Comments Comments h.ArrayType `json:"comments"` // Meta Meta h.DefaultMetaType `json:"meta"` }
ItemDetailCommentsAndMeta provides the comments for an item
type ItemParent ¶
type ItemParent struct { MicrocosmID int64 `json:"microcosmId"` Breadcrumb *[]MicrocosmLinkType `json:"breadcrumb,omitempty"` }
ItemParent describes the ancestor microcosms this item belongs to
func (*ItemParent) FetchBreadcrumb ¶
func (m *ItemParent) FetchBreadcrumb() (int, error)
FetchBreadcrumb will populate the breadcrumb trail (parents) of the current item
type ItemRequest ¶
ItemRequest is an envelope to request an item via a channel
type ItemRequestBySeq ¶
type ItemRequestBySeq []ItemRequest
ItemRequestBySeq it a sorted collection of ItemRequests
func (ItemRequestBySeq) Len ¶
func (v ItemRequestBySeq) Len() int
Len returns the length of the collection
func (ItemRequestBySeq) Less ¶
func (v ItemRequestBySeq) Less(i, j int) bool
Less determines whether an item is greater in sequence than another
func (ItemRequestBySeq) Swap ¶
func (v ItemRequestBySeq) Swap(i, j int)
Swap exchanges two adjacent items in the collection
type ItemSummary ¶
type ItemSummary struct { // Common Fields ID int64 `json:"id"` Title string `json:"title"` ItemParent }
ItemSummary is used by all things that can be a child of a microcosm
type ItemSummaryMeta ¶
type ItemSummaryMeta struct { CommentCount int64 `json:"totalComments"` ViewCount int64 `json:"totalViews"` LastComment interface{} `json:"lastComment,omitempty"` Meta h.SummaryMetaType `json:"meta"` }
ItemSummaryMeta is the meta object for an ItemSummary
type JSONRequestDecoder ¶
type JSONRequestDecoder struct{}
JSONRequestDecoder is a JSON decoder for request body (just a wrapper to json.Unmarshal)
func (*JSONRequestDecoder) Unmarshal ¶
func (d *JSONRequestDecoder) Unmarshal(cx *Context, v interface{}) error
Unmarshal decodes JSON
type LastComment ¶
type LastComment struct { ID int64 `json:"id"` h.CreatedType Valid bool `json:"-"` }
LastComment encapsulates the last common on an item within a microcosm
func GetLastComment ¶
func GetLastComment(itemTypeID int64, itemID int64) (LastComment, int, error)
GetLastComment fetches the last comment on an item
type LegalData ¶
type LegalData struct { CustomerName string CustomerURL string CustomerEmail string LinkToAccountDeactivation string LinkToBestPractises string LinkToCookiePolicy string LinkToFees string LinkToOpenSourceLicenses string LinkToPrivacyPolicy string LinkToVerificationPolicy string CookiePolicyLastModified string PrivacyPolicyLastModified string ServiceAgreementLastModified string TermsOfUseLastModified string LegalEntity string MicrocosmEmail string MicrocosmAddress string }
LegalData is used by the HTML template and provides the values of the strings to be inserted into the HTML templates
type LegalDoc ¶
type LegalDoc struct { Link interface{} `json:"link,omitempty"` HTML string `json:"html,omitempty"` LastModified time.Time `json:"lastModified,omitempty"` }
LegalDoc describes a legal document
type Link ¶
type Link struct { ID int64 Rand string ShortURL string Domain string URL string Text string Created time.Time ResolvedURL sql.NullString Resolved pq.NullTime Hits int64 }
Link describes a link within user generated content
type MetricType ¶
type MetricType struct { Timestamp time.Time Pageviews int32 Visits int32 Uniques int32 NewProfiles int32 EditedProfiles int32 TotalProfiles int32 Signins int32 Comments int32 Conversations int32 EngagedForums int32 TotalForums int32 }
MetricType describes the attributes of all sites on Microcosm
type MicrocosmCore ¶
type MicrocosmCore struct { ID int64 `json:"id"` ParentID int64 `json:"parentId,omitempty"` Breadcrumb *[]MicrocosmLinkType `json:"breadcrumb,omitempty"` SiteID int64 `json:"siteId,omitempty"` Visibility string `json:"visibility"` Title string `json:"title"` Description string `json:"description"` LogoURL string `json:"logoUrl"` LogoURLNullable sql.NullString `json:"-"` ItemTypes []string `json:"itemTypes"` // contains filtered or unexported fields }
MicrocosmCore describes the ancestor microcosms this item belongs to
func (*MicrocosmCore) FetchBreadcrumb ¶
func (m *MicrocosmCore) FetchBreadcrumb() (int, error)
FetchBreadcrumb will determine the ancestor microcosms and establish the breadcrumb trail
type MicrocosmLinkType ¶
type MicrocosmLinkType struct { Rel string `json:"rel,omitempty"` // REST Href string `json:"href"` Title string `json:"title,omitempty"` LogoURL string `json:"logoUrl,omitempty"` ID int64 `json:"id"` Level int64 `json:"level,omitempty"` ParentID int64 `json:"parentId,omitempty"` // contains filtered or unexported fields }
MicrocosmLinkType is a link
func GetMicrocosmTree ¶
func GetMicrocosmTree(siteID int64, profileID int64) ([]MicrocosmLinkType, int, error)
GetMicrocosmTree will return a slice of microcosms that encapsulate a tree of all microcosms
type MicrocosmSummaryRequest ¶
type MicrocosmSummaryRequest struct { Item MicrocosmSummaryType Err error Status int Seq int }
MicrocosmSummaryRequest is an envelope for a microcosm summary
type MicrocosmSummaryRequestBySeq ¶
type MicrocosmSummaryRequestBySeq []MicrocosmSummaryRequest
MicrocosmSummaryRequestBySeq is a collection of requests
func (MicrocosmSummaryRequestBySeq) Len ¶
func (v MicrocosmSummaryRequestBySeq) Len() int
Len returns the length of the collection
func (MicrocosmSummaryRequestBySeq) Less ¶
func (v MicrocosmSummaryRequestBySeq) Less(i, j int) bool
Less determines which item is sequenced lower than the other
func (MicrocosmSummaryRequestBySeq) Swap ¶
func (v MicrocosmSummaryRequestBySeq) Swap(i, j int)
Swap changes the position of two items in the collection
type MicrocosmSummaryType ¶
type MicrocosmSummaryType struct { MicrocosmCore Children interface{} `json:"children,omitempty"` Moderators []int64 `json:"moderators"` ItemCount int64 `json:"totalItems"` CommentCount int64 `json:"totalComments"` MRU interface{} `json:"mostRecentUpdate,omitempty"` Meta h.SummaryMetaType `json:"meta"` }
MicrocosmSummaryType is a summary of a microcosm
func GetMicrocosmSummary ¶
func GetMicrocosmSummary( siteID int64, id int64, profileID int64, ) ( MicrocosmSummaryType, int, error, )
GetMicrocosmSummary fetches a summary of a microcosm
type MicrocosmType ¶
type MicrocosmType struct { MicrocosmCore RemoveLogo bool `json:"removeLogo,omitempty"` OwnedByID int64 `json:"-"` Moderators []int64 `json:"moderators"` Items h.ArrayType `json:"items"` Meta h.DefaultMetaType `json:"meta"` }
MicrocosmType is a microcosm
func GetMicrocosm ¶
GetMicrocosm fetches a microcosm
func (*MicrocosmType) Delete ¶
func (m *MicrocosmType) Delete() (int, error)
Delete removes a microcosm from the database
func (*MicrocosmType) Hydrate ¶
func (m *MicrocosmType) Hydrate( siteID int64, profileID int64, ) ( int, error, )
Hydrate populates a partially populated microcosm struct
func (*MicrocosmType) Import ¶
func (m *MicrocosmType) Import() (int, error)
Import saves the microcosm to the database
func (*MicrocosmType) Insert ¶
func (m *MicrocosmType) Insert() (int, error)
Insert saves the microcosm to the database
func (*MicrocosmType) Patch ¶
func (m *MicrocosmType) Patch( ac AuthContext, patches []h.PatchType, ) ( int, error, )
Patch partially updates a microcosm
func (*MicrocosmType) Update ¶
func (m *MicrocosmType) Update() (int, error)
Update saves changes to the microcosm
type MicrocosmsType ¶
type MicrocosmsType struct { Microcosms h.ArrayType `json:"microcosms"` Meta h.CoreMetaType `json:"meta"` }
MicrocosmsType is a collection of microcosms
type NewUser ¶
type NewUser struct { User UserType Profile ProfileType }
NewUser encapsulates a newly registered user on the site, and provides the structs with the email, profile_name, etc
type OAuthClientType ¶
OAuthClientType describes an OAuth client
func RetrieveClientBySecret ¶
func RetrieveClientBySecret(secret string) (OAuthClientType, error)
RetrieveClientBySecret fetches a client from a client secret
type PermissionType ¶
type PermissionType struct { CanCreate bool `json:"create"` CanRead bool `json:"read"` CanUpdate bool `json:"update"` CanDelete bool `json:"delete"` CanCloseOwn bool `json:"closeOwn"` CanOpenOwn bool `json:"openOwn"` CanReadOthers bool `json:"readOthers"` IsGuest bool `json:"guest"` IsBanned bool `json:"banned"` IsOwner bool `json:"owner"` IsModerator bool `json:"moderator"` IsSiteOwner bool `json:"siteOwner"` Context AuthContext `json:"-"` Valid bool `json:"-"` }
PermissionType describes the permissions against the current authorisation context
func GetPermission ¶
func GetPermission(ac AuthContext) PermissionType
GetPermission returns a permission set for a given auth context
type PersonaRequestType ¶
type PersonaRequestType struct { Assertion string `json:"assertion"` Audience string `json:"audience"` }
PersonaRequestType is a Mozilla Persona request
type PersonaResponseType ¶
type PersonaResponseType struct { Status string Email string Audience string Expires int32 Issuer string }
PersonaResponseType is a Mozilla Persona response
type PollChoiceType ¶
type PollChoiceType struct { ID int64 `json:"id"` Choice string `json:"choice"` Order int64 `json:"order"` Votes int64 `json:"votes"` VoterCount int64 `json:"voterCount"` }
PollChoiceType is a single choice on a poll
type PollSummaryType ¶
type PollSummaryType struct { ItemSummary PollQuestion string `json:"question"` Multi bool `json:"multi"` PollOpen bool `json:"pollOpen"` VotingEndsNullable pq.NullTime `json:"-"` VotingEnds string `json:"pollCloses,omitempty"` ItemSummaryMeta }
PollSummaryType is a summary of a poll
func GetPollSummary ¶
GetPollSummary fetches a summary of a poll
type PollType ¶
type PollType struct { ItemDetail // Type Specific PollQuestion string `json:"question"` Multi bool `json:"multi"` PollOpen bool `json:"pollOpen"` Choices []PollChoiceType `json:"choices,omitempty"` VoterCount int64 `json:"voterCount"` // Type Specific Optional VotingEndsNullable pq.NullTime `json:"-"` VotingEnds string `json:"pollCloses,omitempty"` ItemDetailCommentsAndMeta }
PollType is a poll
type PollsType ¶
type PollsType struct { Polls h.ArrayType `json:"polls"` Meta h.CoreMetaType `json:"meta"` }
PollsType is an array of polls
type ProfileColumn ¶
ProfileColumn describes a column that can be matched on the profiles table for filtering and finding profiles
func GetProfileColumnByCamel ¶
func GetProfileColumnByCamel(key string) (bool, ProfileColumn)
GetProfileColumnByCamel returns a profile column given the camel name
func GetProfileColumnBySnake ¶
func GetProfileColumnBySnake(key string) (bool, ProfileColumn)
GetProfileColumnBySnake returns a profile column given the snake name
func (*ProfileColumn) ValidPredicate ¶
func (m *ProfileColumn) ValidPredicate(predicate string) bool
ValidPredicate returns true if the predicate is valid
type ProfileOptionType ¶
type ProfileOptionType struct { ProfileID int64 `json:"profileId"` ShowDOB bool `json:"showDOB"` ShowDOBYear bool `json:"showDOBYear"` SendEMail bool `json:"sendEmail"` SendSMS bool `json:"sendSMS"` IsDiscouraged bool `json:"isDiscouraged"` }
ProfileOptionType describes the options for a profile
func GetProfileOptions ¶
func GetProfileOptions(profileID int64) (ProfileOptionType, int, error)
GetProfileOptions returns the options for a profile
func GetProfileOptionsDefaults ¶
func GetProfileOptionsDefaults(siteID int64) (ProfileOptionType, int, error)
GetProfileOptionsDefaults returns the default options for this site
func (*ProfileOptionType) Insert ¶
func (m *ProfileOptionType) Insert(tx *sql.Tx) (int, error)
Insert saves the options to the database
func (*ProfileOptionType) Update ¶
func (m *ProfileOptionType) Update() (int, error)
Update saves the updated options for a profile
type ProfileSearchOptions ¶
type ProfileSearchOptions struct { OrderByCommentCount bool IsFollowing bool IsOnline bool StartsWith string ProfileID int64 }
ProfileSearchOptions describes the available ways to search and filter profiles
func GetProfileSearchOptions ¶
func GetProfileSearchOptions(query url.Values) ProfileSearchOptions
GetProfileSearchOptions fetches the options in the querystring that are being used to filter and search for profiles
type ProfileSummaryRequest ¶
type ProfileSummaryRequest struct { Item ProfileSummaryType Err error Status int Seq int }
ProfileSummaryRequest is an envelope to request a profile
type ProfileSummaryRequestBySeq ¶
type ProfileSummaryRequestBySeq []ProfileSummaryRequest
ProfileSummaryRequestBySeq is a collection of profile requests
func (ProfileSummaryRequestBySeq) Len ¶
func (v ProfileSummaryRequestBySeq) Len() int
Len returns the length of the array
func (ProfileSummaryRequestBySeq) Less ¶
func (v ProfileSummaryRequestBySeq) Less(i, j int) bool
Less determines whether one profile is lower in sequence than another
func (ProfileSummaryRequestBySeq) Swap ¶
func (v ProfileSummaryRequestBySeq) Swap(i, j int)
Swap exchanges two items in the array
type ProfileSummaryType ¶
type ProfileSummaryType struct { ID int64 `json:"id"` SiteID int64 `json:"siteId,omitempty"` UserID int64 `json:"userId"` ProfileName string `json:"profileName"` Visible bool `json:"visible"` AvatarURLNullable sql.NullString `json:"-"` AvatarURL string `json:"avatar"` AvatarIDNullable sql.NullInt64 `json:"-"` AvatarID int64 `json:"-"` Meta h.ExtendedMetaType `json:"meta"` }
ProfileSummaryType describes a profile, in summary
func GetProfileSummary ¶
func GetProfileSummary( siteID int64, id int64, ) ( ProfileSummaryType, int, error, )
GetProfileSummary fetches a summary of a profile
func GetProfiles ¶
func GetProfiles( siteID int64, so ProfileSearchOptions, limit int64, offset int64, ) ( []ProfileSummaryType, int64, int64, int, error, )
GetProfiles returns a collection of profiles
func GetRoleMembers ¶
func GetRoleMembers( siteID int64, roleID int64, limit int64, offset int64, ) ( []ProfileSummaryType, int64, int64, int, error, )
GetRoleMembers fetches all profiles who are part of this role, either explicitly so or implicitly so.
func GetRoleProfile ¶
func GetRoleProfile( siteID int64, roleID int64, profileID int64, ) ( ProfileSummaryType, int, error, )
GetRoleProfile returns a single profile for a role
func GetRoleProfiles ¶
func GetRoleProfiles( siteID int64, roleID int64, limit int64, offset int64, ) ( []ProfileSummaryType, int64, int64, int, error, )
GetRoleProfiles fetches multiple profiles belonging to a role
func (*ProfileSummaryType) UpdateUnreadHuddleCount ¶
func (m *ProfileSummaryType) UpdateUnreadHuddleCount()
UpdateUnreadHuddleCount updates the unread huddle count
type ProfileType ¶
type ProfileType struct { ID int64 `json:"id"` SiteID int64 `json:"siteId,omitempty"` UserID int64 `json:"userId"` Email string `json:"email,omitempty"` ProfileName string `json:"profileName"` Member bool `json:"member,omitempty"` GenderNullable sql.NullString `json:"-"` Gender string `json:"gender,omitempty"` Visible bool `json:"visible"` StyleID int64 `json:"styleId"` ItemCount int32 `json:"itemCount"` CommentCount int32 `json:"commentCount"` ProfileComment interface{} `json:"profileComment"` Created time.Time `json:"created"` LastActive time.Time `json:"lastActive"` AvatarURLNullable sql.NullString `json:"-"` AvatarURL string `json:"avatar"` AvatarIDNullable sql.NullInt64 `json:"-"` AvatarID int64 `json:"-"` Meta h.ExtendedMetaType `json:"meta"` }
ProfileType describes a profile
func GetOrCreateProfile ¶
func GetOrCreateProfile( site SiteType, user UserType, ) ( ProfileType, int, error, )
GetOrCreateProfile is called for new logins, to either fetch a profile or create a new one
func GetProfile ¶
func GetProfile(siteID int64, id int64) (ProfileType, int, error)
GetProfile fetches a single profile
func (*ProfileType) Delete ¶
func (m *ProfileType) Delete() (int, error)
Delete removes a profile from the database
func (*ProfileType) GetUnreadHuddleCount ¶
func (m *ProfileType) GetUnreadHuddleCount() (int, error)
GetUnreadHuddleCount fetches the current unread huddle count
func (*ProfileType) Import ¶
func (m *ProfileType) Import() (int, error)
Import provides a public interface for creating a profile by importing an existing profile.
Import performs permissive validation and will return an error only if the data is fundamentally crap. It will repair and fix any data it can, i.e. by replacing spaces in usernames
func (*ProfileType) Insert ¶
func (m *ProfileType) Insert() (int, error)
Insert provides a public interface for creating a profile.
Insert performs strict validation and will return an error if the data is not very good (i.e. username contains a space and created date was supplied)
func (*ProfileType) Patch ¶
func (m *ProfileType) Patch( ac AuthContext, patches []h.PatchType, ) ( int, error, )
Patch partially updates a profile
func (*ProfileType) Update ¶
func (m *ProfileType) Update() (int, error)
Update saves the current version of the profile to the database
func (*ProfileType) UpdateUnreadHuddleCount ¶
func (m *ProfileType) UpdateUnreadHuddleCount()
UpdateUnreadHuddleCount updates the unread huddle count
type ProfilesType ¶
type ProfilesType struct { Profiles h.ArrayType `json:"profiles"` Meta h.ExtendedMetaType `json:"meta"` }
ProfilesType encapsulates a collection of profiles
type ReadScopeType ¶
type ReadScopeType struct { ItemID int64 `json:"itemId"` ItemType string `json:"itemType"` ItemTypeID int64 }
ReadScopeType describes the item to be considered read
type RequestDecoder ¶
RequestDecoder unmarshal types that implement RequestDecoder into an apropriate type/struct
type RewriteRule ¶
type RewriteRule struct { ID int64 Title string RegexMatch string RegexReplace string Enabled bool FetchTitle bool Sequence int Valid bool }
RewriteRule describes a matching HTML string and a regex replacement
type RoleCriteriaType ¶
type RoleCriteriaType struct { RoleCriteria h.ArrayType `json:"criteria"` Meta h.CoreMetaType `json:"meta"` }
RoleCriteriaType describes a collection of criterion
type RoleCriterionRequest ¶
type RoleCriterionRequest struct { Item RoleCriterionType Err error Status int Seq int }
RoleCriterionRequest describes a channel envelope for a role criterion
type RoleCriterionRequestBySeq ¶
type RoleCriterionRequestBySeq []RoleCriterionRequest
RoleCriterionRequestBySeq describes an ordered array of requests
func (RoleCriterionRequestBySeq) Len ¶
func (v RoleCriterionRequestBySeq) Len() int
Len returns the len of the array
func (RoleCriterionRequestBySeq) Less ¶
func (v RoleCriterionRequestBySeq) Less(i, j int) bool
Less determines which item is considered lesser than another in the array
func (RoleCriterionRequestBySeq) Swap ¶
func (v RoleCriterionRequestBySeq) Swap(i, j int)
Swap exchanges two items in the array by ordinal position
type RoleCriterionType ¶
type RoleCriterionType struct { ID int64 `json:"id,omitempty"` OrGroup int64 `json:"orGroup"` ProfileColumn string `json:"profileColumn,omitempty"` ProfileColumnNullable sql.NullString `json:"-"` AttrKey string `json:"attrKey,omitempty"` AttrKeyNullable sql.NullString `json:"-"` Predicate string `json:"predicate"` Value interface{} `json:"value,omitempty"` ValueString string `json:"-"` Type string `json:"-"` }
RoleCriterionType describes one criterion
func GetRoleCriteria ¶
func GetRoleCriteria( roleID int64, limit int64, offset int64, ) ( []RoleCriterionType, int64, int64, int, error, )
GetRoleCriteria fetches a criteria
func GetRoleCriterion ¶
func GetRoleCriterion(id int64, roleID int64) (RoleCriterionType, int, error)
GetRoleCriterion fetches a single criterion from the database
func (*RoleCriterionType) Delete ¶
func (m *RoleCriterionType) Delete(roleID int64) (int, error)
Delete removes a single criterion from the database
func (*RoleCriterionType) GetLink ¶
func (m *RoleCriterionType) GetLink(roleLink string) string
GetLink returns a link to this criterion
func (*RoleCriterionType) Insert ¶
func (m *RoleCriterionType) Insert(roleID int64) (int, error)
Insert saves the criterion to the database
type RoleMetaType ¶
type RoleMetaType struct { h.CreatedType h.EditedType Links []h.LinkType `json:"links,omitempty"` Permissions interface{} `json:"permissions,omitempty"` }
RoleMetaType is a reduced meta JSON holder for roles
type RoleProfileType ¶
type RoleProfileType struct { ID int64 `json:"id,omitempty"` Profile interface{} `json:"profile"` }
RoleProfileType describes a profile that belongs to a role
func (*RoleProfileType) Delete ¶
func (m *RoleProfileType) Delete(roleID int64) (int, error)
Delete removes a profile from a role
func (*RoleProfileType) GetLink ¶
func (m *RoleProfileType) GetLink(roleLink string) string
GetLink returns an API link to this role profile
type RoleProfilesType ¶
type RoleProfilesType struct { RoleProfiles h.ArrayType `json:"profiles"` Meta h.CoreMetaType `json:"meta"` }
RoleProfilesType is an array of RoleProfileType
type RoleSummaryType ¶
RoleSummaryType is a summary of a role
func GetRoleSummary ¶
func GetRoleSummary( siteID int64, microcosmID int64, roleID int64, profileID int64, ) ( RoleSummaryType, int, error, )
GetRoleSummary fetches a summary of a role from the database
type RoleType ¶
type RoleType struct { ID int64 `json:"id"` Title string `json:"title"` SiteID int64 `json:"siteId,omitempty"` MicrocosmID int64 `json:"microcosmId,omitempty"` MicrocosmIDNullable sql.NullInt64 `json:"-"` IsModerator bool `json:"moderator"` IsBanned bool `json:"banned"` IncludeGuests bool `json:"includeGuests"` IncludeUsers bool `json:"includeUsers"` CanCreate bool `json:"create"` CanRead bool `json:"read"` CanUpdate bool `json:"update"` CanDelete bool `json:"delete"` CanCloseOwn bool `json:"closeOwn"` CanOpenOwn bool `json:"openOwn"` CanReadOthers bool `json:"readOthers"` Meta RoleMetaType `json:"meta"` // These two are used by the importer and should not be JSON exported Criteria []RoleCriterionType `json:"-"` Profiles []RoleProfileType `json:"-"` }
RoleType encapsulates a role, including who can do what. It is a whitelist
func GetRole ¶
func GetRole( siteID int64, microcosmID int64, roleID int64, profileID int64, ) ( RoleType, int, error, )
GetRole fetches a role from the database
type RolesType ¶
type RolesType struct { DefaultRoles bool `json:"defaultRoles,omitempty"` Roles h.ArrayType `json:"roles"` Meta h.CoreMetaType `json:"meta"` }
RolesType is a collection of roles
type SearchQuery ¶
type SearchQuery struct { URL url.URL `json:"-"` URLValues url.Values `json:"-"` // Implemented in search Query string `json:"q,omitempty"` InTitle bool `json:"inTitle,omitempty"` MicrocosmIDsQuery []int64 `json:"forumId,omitempty"` MicrocosmIDs []int64 `json:"-"` ItemTypesQuery []string `json:"type,omitempty"` ItemTypeIDs []int64 `json:"-"` ItemIDsQuery []int64 `json:"id,omitempty"` ItemIDs []int64 `json:"-"` ProfileID int64 `json:"authorId,omitempty"` Emails []string `json:"email,omitempty"` Following bool `json:"following,omitempty"` Since string `json:"since,omitempty"` SinceTime time.Time `json:"-"` Until string `json:"until,omitempty"` UntilTime time.Time `json:"-"` EventAfter string `json:"eventAfter,omitempty"` EventAfterTime time.Time `json:"-"` EventBefore string `json:"eventBefore,omitempty"` EventBeforeTime time.Time `json:"-"` Attendee bool `json:"attendee,omitempty"` Has []string `json:"has,omitempty"` Sort string `json:"sort,omitempty"` Limit int64 `json:"-"` Offset int64 `json:"-"` // Not yet implement in search Lat float64 `json:"lat,omitempty"` Lon float64 `json:"lon,omitempty"` Radius int64 `json:"radius,omitempty"` North float64 `json:"north,omitempty"` East float64 `json:"east,omitempty"` South float64 `json:"south,omitempty"` West float64 `json:"west,omitempty"` ProfileName string `json:"author,omitempty"` Ignored string `json:"ignored,omitempty"` IgnoredArr []string `json:"-"` Searched string `json:"searched,omitempty"` Valid bool `json:"-"` }
SearchQuery encapsulates all of the meta parts of a search over the microcosm content
func GetSearchQueryFromURL ¶
func GetSearchQueryFromURL( siteID int64, requestURL url.URL, profileID int64, ) SearchQuery
GetSearchQueryFromURL fetches and parses a query and returns a SearchQuery
func (*SearchQuery) ParseBool ¶
func (sq *SearchQuery) ParseBool(key string, value string, frag string)
ParseBool parses a boolean arg
func (*SearchQuery) ParseDateTime ¶
func (sq *SearchQuery) ParseDateTime(key string, value string, frag string)
ParseDateTime parses a string containing a potential datetime arg
func (*SearchQuery) ParseFloat ¶
func (sq *SearchQuery) ParseFloat(key string, value string, frag string)
ParseFloat parses a float arg
func (*SearchQuery) ParseFullQueryString ¶
func (sq *SearchQuery) ParseFullQueryString()
ParseFullQueryString takes ?q=term&type=conversation And makes it
q = term type = conversation
Within the sq object
func (*SearchQuery) ParseInt ¶
func (sq *SearchQuery) ParseInt(key string, value string, frag string)
ParseInt parses an integer arg
func (*SearchQuery) ParseSingleQueryValue ¶
func (sq *SearchQuery) ParseSingleQueryValue()
ParseSingleQueryValue takes the value of sq.Query which came from the querystring 'q' and sees whether there are things like type:conversation and if so will populate sq.* accordingly
func (*SearchQuery) Validate ¶
func (sq *SearchQuery) Validate(siteID int64, profileID int64)
Validate returns true if the query is valid
type SearchResult ¶
type SearchResult struct { ItemType string `json:"itemType"` ItemTypeID int64 `json:"-"` ItemID int64 `json:"-"` Item interface{} `json:"item"` ParentItemType string `json:"parentItemType,omitempty"` ParentItemTypeID sql.NullInt64 `json:"-"` ParentItemID sql.NullInt64 `json:"-"` ParentItem interface{} `json:"parentItem,omitempty"` Unread bool `json:"unread"` // TODO(buro9): Remove rank Rank float64 `json:"rank"` LastModified time.Time `json:"lastModified"` Highlight string `json:"highlight"` }
SearchResult is an encapsulation of a hit against a search
type SearchResults ¶
type SearchResults struct { Query SearchQuery `json:"query"` TimeTaken int64 `json:"timeTakenInMs,omitempty"` Results interface{} `json:"results,omitempty"` }
SearchResults is a list of SearchResult
type SiteHealthAttribute ¶
type SiteHealthAttribute struct { Set bool `json:"set"` Valid bool `json:"valid"` Error string `json:"error"` Value interface{} `json:"value"` }
SiteHealthAttribute encapsulates a state for site configuration
type SiteHealthType ¶
type SiteHealthType struct { Site SiteType `json:"site"` DomainHealth SiteHealthAttribute `json:"domainHealth"` BackgroundURLHealth SiteHealthAttribute `json:"backgroundUrlHealth"` LogoURLHealth SiteHealthAttribute `json:"logoUrlHealth"` AnalyticsIDHealth SiteHealthAttribute `json:"analyticsIDHealth"` }
SiteHealthType encapsulates the state of the site configuration
func CheckSiteHealth ¶
func CheckSiteHealth(site SiteType) (SiteHealthType, int, error)
CheckSiteHealth checks for valid domain, analytics, and logo/background settings.
type SiteStatType ¶
type SiteStatType struct { ActiveProfiles int64 OnlineProfiles int64 TotalProfiles int64 TotalConvs int64 TotalEvents int64 TotalComments int64 }
SiteStatType encapsulates global stats for the site
func CalcSiteStats ¶
func CalcSiteStats(siteID int64) (SiteStatType, error)
CalcSiteStats is expensive and should not be run to synchronously service a request.
type SiteType ¶
type SiteType struct { ID int64 `json:"siteId"` SiteURL string `json:"siteURL"` Title string `json:"title"` Description string `json:"description"` SubdomainKey string `json:"subdomainKey"` Domain string `json:"domain"` DomainNullable sql.NullString `json:"-"` ForceSSL bool `json:"forceSSL,omitempty"` OwnedByID int64 `json:"-"` OwnedBy interface{} `json:"ownedBy"` ThemeID int64 `json:"themeId"` LogoURL string `json:"logoUrl"` FaviconURL string `json:"faviconUrl,omitempty"` BackgroundColor string `json:"backgroundColor"` BackgroundURL string `json:"backgroundUrl,omitempty"` BackgroundPosition string `json:"backgroundPosition,omitempty"` LinkColor string `json:"linkColor"` GaWebPropertyID string `json:"gaWebPropertyId,omitempty"` GaWebPropertyIDNullable sql.NullString `json:"-"` Menu []h.LinkType `json:"menu"` Auth0DomainNullable sql.NullString `json:"-"` Auth0Domain string `json:"auth0Domain,omitempty"` Auth0ClientIDNullable sql.NullString `json:"-"` Auth0ClientID string `json:"auth0ClientId,omitempty"` Auth0ClientSecretNullable sql.NullString `json:"-"` Auth0ClientSecret string `json:"-"` Meta struct { h.CreatedType h.EditedType Flags struct { Deleted bool `json:"deleted"` } `json:"flags,omitempty"` h.CoreMetaType } `json:"meta"` }
SiteType is the grandaddy of all types and describes a site
func GetSiteByDomain ¶
GetSiteByDomain returns a site for a given custom domain name
func GetSiteBySubdomain ¶
GetSiteBySubdomain returns a site for a given subdomain key
func (*SiteType) GetURL ¶
GetURL builds a site URL depending on whether or not it is a subdomain or custom domain
type SitesType ¶
type SitesType struct { Sites h.ArrayType `json:"sites"` Meta h.CoreMetaType `json:"meta"` }
SitesType is an array of sites
type StandardResponse ¶
type StandardResponse struct { Context string `json:"context"` Status int `json:"status"` Data interface{} `json:"data"` Errors []string `json:"error"` }
StandardResponse is a sruct wrapping all API responses with a boiler-plate
type SummaryContainer ¶
type SummaryContainer struct { ItemTypeID int64 `json:"-"` ItemType string `json:"itemType"` ItemID int64 `json:"-"` Summary interface{} `json:"item"` Valid bool `json:"-"` }
SummaryContainer stores a summary of an item
func GetAllItems ¶
func GetAllItems( siteID int64, microcosmID int64, profileID int64, limit int64, offset int64, ) ( []SummaryContainer, int64, int64, int, error, )
GetAllItems fetches items within a microcosm
func GetMostRecentItem ¶
func GetMostRecentItem( siteID int64, microcosmID int64, profileID int64, ) ( SummaryContainer, int, error, )
GetMostRecentItem fetches the most recently updated item within a microcosm
func GetRootMicrocosm ¶
func GetRootMicrocosm( siteID int64, profileID int64, limit int64, offset int64, ) ( []SummaryContainer, int64, int64, int, error, )
GetRootMicrocosm fetches the root microcosm and it's contents
func GetSummaryContainer ¶
func GetSummaryContainer( siteID int64, itemTypeID int64, itemID int64, profileID int64, ) ( SummaryContainer, int, error, )
GetSummaryContainer wraps GetSummary
type SummaryContainerRequest ¶
type SummaryContainerRequest struct { Item SummaryContainer Err error Status int Seq int }
SummaryContainerRequest allows a request to be passed by a channel and the error, status and sequence of responses to be encapsulated
type SummaryContainerRequestsBySeq ¶
type SummaryContainerRequestsBySeq []SummaryContainerRequest
SummaryContainerRequestsBySeq is an array of requests
func (SummaryContainerRequestsBySeq) Len ¶
func (v SummaryContainerRequestsBySeq) Len() int
Len gives the length of the array
func (SummaryContainerRequestsBySeq) Less ¶
func (v SummaryContainerRequestsBySeq) Less(i, j int) bool
Less determines whether the given items are above or below each other in the array
func (SummaryContainerRequestsBySeq) Swap ¶
func (v SummaryContainerRequestsBySeq) Swap(i, j int)
Swap allows re-ordering of array elements by swapping them around
type ThreadedMetaType ¶
type ThreadedMetaType struct { InReplyTo interface{} `json:"inReplyTo,omitempty"` Replies []interface{} `json:"replies,omitempty"` CommentMetaType }
ThreadedMetaType encapsulates a threaded part of a comment tree
type TrendingItem ¶
type TrendingItem struct { ItemType string `json:"itemType"` ItemTypeID int64 `json:"-"` ItemID int64 `json:"-"` Item interface{} `json:"item"` Score int64 `json:"-"` }
TrendingItem encapsulates a list of items currently trending
type TrendingItems ¶
type TrendingItems struct { Items h.ArrayType `json:"items"` Meta h.CoreMetaType `json:"meta"` }
TrendingItems is an array of TrendingItem
type UpdateDefaultOptionType ¶
type UpdateDefaultOptionType struct { UpdateTypeID int64 `json:"id"` SendEmail bool `json:"sendEmail"` SendSMS bool `json:"sendSMS"` }
UpdateDefaultOptionType contains the default communication options
type UpdateOptionType ¶
type UpdateOptionType struct { ProfileID int64 `json:"profileId"` UpdateTypeID int64 `json:"id"` Description string `json:"description"` SendEmail bool `json:"sendEmail"` SendSMS bool `json:"sendSMS"` Meta h.CoreMetaType `json:"meta"` }
UpdateOptionType contains a user preference for a communication option
func GetCommunicationOptions ¶
func GetCommunicationOptions( siteID int64, profileID int64, updateTypeID int64, itemTypeID int64, itemID int64, ) ( UpdateOptionType, int, error, )
GetCommunicationOptions returns a user's update options if present, otherwise it returns the default preference for the given update type.
func GetUpdateOptionByUpdateType ¶
func GetUpdateOptionByUpdateType( profileID int64, updateTypeID int64, ) ( UpdateOptionType, int, error, )
GetUpdateOptionByUpdateType returns the notification settings (email, sms) for a given user and update type.
func GetUpdateOptions ¶
func GetUpdateOptions( siteID int64, profileID int64, ) ( []UpdateOptionType, int, error, )
GetUpdateOptions retrieves a user's alert preferences for all available alert types. This is not paginated since the collection should always fit on a single page.
func (*UpdateOptionType) Delete ¶
func (m *UpdateOptionType) Delete() (int, error)
Delete removes an update option record for a specific user. Generally this will be unnecessary unless a user needs to clear their preferences completely and return to the defaults.
func (*UpdateOptionType) Insert ¶
func (m *UpdateOptionType) Insert() (int, error)
Insert creates a communication option to the database
func (*UpdateOptionType) Update ¶
func (m *UpdateOptionType) Update() (int, error)
Update saves the communication preferences for an UpdateOptionType to the database
func (*UpdateOptionType) Validate ¶
func (m *UpdateOptionType) Validate() (int, error)
Validate returns true if the integrity of the communications option is valid
type UpdateRecipient ¶
type UpdateRecipient struct { Watcher WatcherType ForProfile ProfileSummaryType SendEmail bool SendSMS bool LastNotifiedNullable pq.NullTime LastNotified time.Time }
UpdateRecipient distills watchers and communications options into a single actionable and switchable thing
func GetUpdateRecipients ¶
func GetUpdateRecipients( siteID int64, itemTypeID int64, itemID int64, updateTypeID int64, createdByID int64, ) ( []UpdateRecipient, int, error, )
GetUpdateRecipients returns the update recipients for a given item that has been updated
type UpdateType ¶
type UpdateType struct { ID int64 `json:"id"` SiteID int64 `json:"-"` ForProfileID int64 `json:"-"` UpdateTypeID int64 `json:"-"` UpdateType string `json:"updateType"` ItemTypeID int64 `json:"-"` ItemType string `json:"itemType"` ItemID int64 `json:"-"` Item interface{} `json:"item,omitempty"` ParentItemTypeID int64 `json:"-"` ParentItemType string `json:"parentItemType,omitempty"` ParentItemID int64 `json:"-"` ParentItem interface{} `json:"parentItem,omitempty"` Meta h.CreatedMetaType `json:"meta"` }
UpdateType encapsulates an update that for occured on an item that we are recording for a profile so that we can show them their updates and send notifications based on them.
func GetUpdates ¶
func GetUpdates( siteID int64, profileID int64, limit int64, offset int64, ) ( []UpdateType, int64, int64, int, error, )
GetUpdates retieves the list of updates for the given profile
func (*UpdateType) Hydrate ¶
func (m *UpdateType) Hydrate(siteID int64) (int, error)
Hydrate fetches profile/item summary for a update entry. Called post SELECT or post-GetFromCache
func (*UpdateType) Insert ¶
func (m *UpdateType) Insert() (int, error)
Insert stores the UpdateType in the database
type UpdateTypesType ¶
type UpdateTypesType struct { ID int64 `json:"id"` Title string `json:"title"` Description string `json:"description"` EmailSubject string `json:"emailSubject"` EmailBodyText string `json:"emailBodyText"` EmailBodyHTML string `json:"emailBodyHtml"` }
UpdateTypesType is an unwieldy name, but it convenes to how all other table structs are named (the table is `UpdateType`)
func GetUpdateType ¶
func GetUpdateType(updateTypeID int64) (UpdateTypesType, int, error)
GetUpdateType retrieves an email update template for a given update type
type UpdatesType ¶
type UpdatesType struct { Updates h.ArrayType `json:"updates"` Meta h.CoreMetaType `json:"meta"` }
UpdatesType is an array of UpdateType
type Usage ¶
type Usage struct { Method string URL string EndPointURL string UserAgent string HTTPStatus int IPAddr string Host string ContentLength int Created string `json:"timestamp"` TimeSpent int64 AccessToken string SiteID int64 UserID int64 ProfileID int64 Error string }
Usage encapsulates a request and the key metrics and info around the request such as the time spent serving it, who asked for it, the endpoint, etc
type UserMembership ¶
type UserMembership struct { Email string `json:"email"` IsMember bool `json:"isMember"` // contains filtered or unexported fields }
UserMembership is for managing user permissions
type UserType ¶
type UserType struct { ID int64 `json:"userId"` Email string `json:"email"` Gender sql.NullString `json:"gender,omitempty"` Language string `json:"language,omitempty"` Created time.Time `json:"created"` State sql.NullString `json:"state"` Banned bool `json:"banned,omitempty"` Password string `json:"-"` PasswordDate time.Time `json:"-"` DobDay sql.NullInt64 `json:"dobDay,omitempty"` DobMonth sql.NullInt64 `json:"dobMonth,omitempty"` DobYear sql.NullInt64 `json:"dobYear,omitempty"` CanonicalEmail string `json:"canonicalEmail,omitempty"` Meta h.CoreMetaType `json:"meta"` }
UserType encapsulates a user in the system
func CreateUserByEmailAddress ¶
CreateUserByEmailAddress creates a stub user from an email address
func GetUserByEmailAddress ¶
GetUserByEmailAddress performs a case-insensitive search for any matching user and returns it.
type UsersType ¶
type UsersType struct { Users h.ArrayType `json:"users"` Meta h.CoreMetaType `json:"meta"` }
UsersType offers an array of users
type WatcherType ¶
type WatcherType struct { ID int64 `json:"id"` ProfileID int64 `json:"-"` ItemTypeID int64 `json:"itemTypeId"` ItemID int64 `json:"itemId"` LastNotifiedNullable pq.NullTime `json:"-"` LastNotified time.Time `json:"lastNotified,omitempty"` SendEmail bool `json:"sendEmail"` SendSMS bool `json:"sendSMS"` Item interface{} `json:"item"` ItemType string `json:"itemType"` }
WatcherType encapsulates a single instance of an item being watched by a profile and the communication preferences
func GetProfileWatchers ¶
func GetProfileWatchers( profileID int64, siteID int64, limit int64, offset int64, ) ( []WatcherType, int64, int64, int, error, )
GetProfileWatchers fetches all watchers registered to a particular profile. This is mainly used for showing a list of watchers to the user.
func GetWatcher ¶
func GetWatcher(watcherID int64, siteID int64) (WatcherType, int, error)
GetWatcher returns a given watcher
func (*WatcherType) Delete ¶
func (m *WatcherType) Delete() (int, error)
Delete removes a watcher from the database and cache
func (*WatcherType) Import ¶
func (m *WatcherType) Import() (int, error)
Import stores the watcher type without performing validation
func (*WatcherType) Insert ¶
func (m *WatcherType) Insert() (int, error)
Insert stores the WatcherType in the database
func (*WatcherType) Update ¶
func (m *WatcherType) Update() (int, error)
Update updates the watcher in the database
func (*WatcherType) UpdateLastNotified ¶
func (m *WatcherType) UpdateLastNotified() (int, error)
UpdateLastNotified updates a watcher according to the last time that watcher triggered a notification. The purpose is to record any contact so that we can avoid multiple notifications for a given item
type WatchersType ¶
type WatchersType struct { Watchers h.ArrayType `json:"watchers"` Meta h.CoreMetaType `json:"meta"` }
WatchersType offers an array of watchers
Source Files ¶
- attachments.go
- attendees.go
- attributes.go
- authentication.go
- authorisation.go
- bans.go
- bbcode.go
- cache.go
- comments.go
- context.go
- conversations.go
- cron.go
- email.go
- events.go
- file.go
- hashtags.go
- huddle_participants.go
- huddles.go
- ignores.go
- init.go
- items.go
- legal.go
- legal_text.go
- link_embedmedia.go
- link_shortener.go
- links.go
- markdown.go
- mentions.go
- menu.go
- metrics.go
- microcosms.go
- package.go
- polls.go
- profile_options.go
- profiles.go
- read.go
- role_criteria.go
- role_members.go
- role_profiles.go
- roles.go
- sanitise.go
- search.go
- search_email.go
- search_fulltext.go
- search_metadata.go
- search_query.go
- sites.go
- stopforumspam.go
- summaries.go
- trending.go
- update_options.go
- update_recipient.go
- update_types.go
- updates.go
- updates_dispatcher.go
- usage.go
- users.go
- watchers.go