models

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//IdeaOpen is the default status
	IdeaOpen = 0
	//IdeaStarted is used when the idea has been accepted and work is in progress
	IdeaStarted = 1
	//IdeaCompleted is used when the idea has been accepted and already implemented
	IdeaCompleted = 2
	//IdeaDeclined is used when organizers decide to decline an idea
	IdeaDeclined = 3
	//IdeaPlanned is used when organizers have accepted an idea and it's on the roadmap
	IdeaPlanned = 4
	//IdeaDuplicate is used when the idea has already been posted before
	IdeaDuplicate = 5
	//IdeaDeleted is used when the idea is completely removed from the site and should never be shown again
	IdeaDeleted = 6
)
View Source
var (
	//SubscriberInactive means that the user cancelled the subscription
	SubscriberInactive = 0
	//SubscriberActive means that the subscription is active
	SubscriberActive = 1
)
View Source
var (
	//NotificationEventNewIdea is triggered when a new idea is posted
	NotificationEventNewIdea = NotificationEvent{
		UserSettingsKeyName:          "event_notification_new_idea",
		DefaultSettingValue:          strconv.Itoa(int(NotificationChannelWeb | NotificationChannelEmail)),
		RequiresSubscripionUserRoles: []Role{},
		DefaultEnabledUserRoles: []Role{
			RoleAdministrator,
			RoleCollaborator,
		},
		Validate: notificationEventValidation,
	}
	//NotificationEventNewComment is triggered when a new comment is posted
	NotificationEventNewComment = NotificationEvent{
		UserSettingsKeyName: "event_notification_new_comment",
		DefaultSettingValue: strconv.Itoa(int(NotificationChannelWeb | NotificationChannelEmail)),
		RequiresSubscripionUserRoles: []Role{
			RoleVisitor,
		},
		DefaultEnabledUserRoles: []Role{
			RoleAdministrator,
			RoleCollaborator,
			RoleVisitor,
		},
		Validate: notificationEventValidation,
	}
	//NotificationEventChangeStatus is triggered when a new idea has its status changed
	NotificationEventChangeStatus = NotificationEvent{
		UserSettingsKeyName: "event_notification_change_status",
		DefaultSettingValue: strconv.Itoa(int(NotificationChannelWeb | NotificationChannelEmail)),
		RequiresSubscripionUserRoles: []Role{
			RoleVisitor,
		},
		DefaultEnabledUserRoles: []Role{
			RoleAdministrator,
			RoleCollaborator,
			RoleVisitor,
		},
		Validate: notificationEventValidation,
	}
	//AllNotificationEvents contains all possible notification events
	AllNotificationEvents = []NotificationEvent{
		NotificationEventNewIdea,
		NotificationEventNewComment,
		NotificationEventChangeStatus,
	}
)
View Source
var (
	//TenantActive is the default status for most tenants
	TenantActive = 1
	//TenantInactive is used for signup via email that requires user confirmation
	TenantInactive = 2
)
View Source
var (
	//UserActive is the default status for users
	UserActive = 1
	//UserDeleted is used for users that chose to delete their accounts
	UserDeleted = 2
)

Functions

func GenerateVerificationKey added in v0.12.0

func GenerateVerificationKey() string

GenerateVerificationKey used on email verifications

func GetIdeaStatusName added in v0.10.0

func GetIdeaStatusName(status int) string

GetIdeaStatusName returns the name of an idea status

Types

type AssignUnassignTag added in v0.8.0

type AssignUnassignTag struct {
	Slug   string `route:"slug"`
	Number int    `route:"number"`
}

AssignUnassignTag is used to assign or remove a tag to/from an idea

type ChangeUserEmail added in v0.9.0

type ChangeUserEmail struct {
	Email           string `json:"email" format:"lower"`
	VerificationKey string
	Requestor       *User
}

ChangeUserEmail is the input model used to change current user's email

func (*ChangeUserEmail) GetEmail added in v0.9.0

func (e *ChangeUserEmail) GetEmail() string

GetEmail returns the email being verified

func (*ChangeUserEmail) GetKind added in v0.9.0

GetKind returns EmailVerificationKindSignIn

func (*ChangeUserEmail) GetName added in v0.9.0

func (e *ChangeUserEmail) GetName() string

GetName returns empty for this kind of process

func (*ChangeUserEmail) GetUser added in v0.9.0

func (e *ChangeUserEmail) GetUser() *User

GetUser returns the current user performing this action

type ChangeUserRole added in v0.7.0

type ChangeUserRole struct {
	UserID int  `route:"user_id"`
	Role   Role `json:"role"`
}

ChangeUserRole is the input model change role of an user

type Comment

type Comment struct {
	ID        int        `json:"id"`
	Content   string     `json:"content"`
	CreatedOn time.Time  `json:"createdOn"`
	User      *User      `json:"user"`
	EditedOn  *time.Time `json:"editedOn"`
	EditedBy  *User      `json:"editedBy"`
}

Comment represents an user comment on an idea

type CompleteProfile added in v0.6.0

type CompleteProfile struct {
	Key   string `json:"key"`
	Name  string `json:"name"`
	Email string
}

CompleteProfile is the model used to complete user profile during email sign in

type CreateEditTag added in v0.8.0

type CreateEditTag struct {
	Slug     string `route:"slug"`
	Name     string `json:"name"`
	Color    string `json:"color" format:"upper"`
	IsPublic bool   `json:"isPublic"`
}

CreateEditTag is used to create a new tag or edit existing

type CreateTenant added in v0.5.0

type CreateTenant struct {
	Token           string `json:"token"`
	Name            string `json:"name"`
	Email           string `json:"email" format:"lower"`
	VerificationKey string
	TenantName      string `json:"tenantName"`
	LegalAgreement  bool   `json:"legalAgreement"`
	Subdomain       string `json:"subdomain" format:"lower"`
	UserClaims      *OAuthClaims
}

CreateTenant is the input model used to create a tenant

func (*CreateTenant) GetEmail added in v0.9.0

func (e *CreateTenant) GetEmail() string

GetEmail returns the email being verified

func (*CreateTenant) GetKind added in v0.9.0

func (e *CreateTenant) GetKind() EmailVerificationKind

GetKind returns EmailVerificationKindSignUp

func (*CreateTenant) GetName added in v0.9.0

func (e *CreateTenant) GetName() string

GetName returns the name of the email owner

func (*CreateTenant) GetUser added in v0.9.0

func (e *CreateTenant) GetUser() *User

GetUser returns the current user performing this action

type DeleteIdea added in v0.11.0

type DeleteIdea struct {
	Number int    `route:"number"`
	Text   string `json:"text"`
}

DeleteIdea represents a request to delete an existing idea

type DeleteTag added in v0.8.0

type DeleteTag struct {
	Slug string `route:"slug"`
}

DeleteTag is used to delete an existing tag

type EditComment added in v0.11.0

type EditComment struct {
	IdeaNumber int    `route:"number"`
	ID         int    `route:"id"`
	Content    string `json:"content"`
}

EditComment represents a request to edit existing comment

type EmailVerification added in v0.9.0

type EmailVerification struct {
	Email      string
	Name       string
	Key        string
	UserID     int
	Kind       EmailVerificationKind
	CreatedOn  time.Time
	ExpiresOn  time.Time
	VerifiedOn *time.Time
}

EmailVerification is the model used by email verification process

type EmailVerificationKind added in v0.9.0

type EmailVerificationKind int16

EmailVerificationKind specifies which kind of process is being verified by email

const (
	//EmailVerificationKindSignIn is the sign in by email process
	EmailVerificationKindSignIn EmailVerificationKind = 1
	//EmailVerificationKindSignUp is the sign up (create tenant) by name and email process
	EmailVerificationKindSignUp EmailVerificationKind = 2
	//EmailVerificationKindChangeEmail is the change user email process
	EmailVerificationKindChangeEmail EmailVerificationKind = 3
	//EmailVerificationKindUserInvitation is the sign in invitation sent to an user
	EmailVerificationKindUserInvitation EmailVerificationKind = 4
)

type FiderClaims

type FiderClaims struct {
	UserID    int    `json:"user/id"`
	UserName  string `json:"user/name"`
	UserEmail string `json:"user/email"`
	jwt.StandardClaims
}

FiderClaims represents what goes into JWT tokens

type Idea

type Idea struct {
	ID              int           `json:"id"`
	Number          int           `json:"number"`
	Title           string        `json:"title"`
	Slug            string        `json:"slug"`
	Description     string        `json:"description"`
	CreatedOn       time.Time     `json:"createdOn"`
	User            *User         `json:"user"`
	ViewerSupported bool          `json:"viewerSupported"`
	TotalSupporters int           `json:"totalSupporters"`
	TotalComments   int           `json:"totalComments"`
	Status          int           `json:"status"`
	Response        *IdeaResponse `json:"response"`
	Tags            []string      `json:"tags"`
}

Idea represents an idea on a tenant board

func (*Idea) CanBeSupported added in v0.9.0

func (i *Idea) CanBeSupported() bool

CanBeSupported returns true if this idea can be Supported/UnSupported

type IdeaResponse

type IdeaResponse struct {
	Text        string        `json:"text"`
	RespondedOn time.Time     `json:"respondedOn"`
	User        *User         `json:"user"`
	Original    *OriginalIdea `json:"original"`
}

IdeaResponse is a staff response to a given idea

type InviteUsers added in v0.12.0

type InviteUsers struct {
	Subject    string   `json:"subject"`
	Message    string   `json:"message"`
	Recipients []string `json:"recipients" format:"lower"`
}

InviteUsers is used to invite new users into Fider

type NewComment added in v0.5.0

type NewComment struct {
	Number  int    `route:"number"`
	Content string `json:"content"`
}

NewComment represents a new comment

type NewEmailVerification added in v0.9.0

type NewEmailVerification interface {
	GetEmail() string
	GetName() string
	GetUser() *User
	GetKind() EmailVerificationKind
}

NewEmailVerification is used to register a new email verification process

type NewIdea added in v0.5.0

type NewIdea struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

NewIdea represents a new idea

type Notification added in v0.10.0

type Notification struct {
	ID        int       `json:"id" db:"id"`
	Title     string    `json:"title" db:"title"`
	Link      string    `json:"link" db:"link"`
	Read      bool      `json:"read" db:"read"`
	CreatedOn time.Time `json:"createdOn" db:"created_on"`
}

Notification is the system generated notification entity

type NotificationChannel added in v0.10.0

type NotificationChannel int

NotificationChannel represents the medium that the notification is sent

var (
	//NotificationChannelWeb is a in-app notification
	NotificationChannelWeb NotificationChannel = 1
	//NotificationChannelEmail is an email notification
	NotificationChannelEmail NotificationChannel = 2
)

type NotificationEvent added in v0.10.0

type NotificationEvent struct {
	UserSettingsKeyName          string
	DefaultSettingValue          string
	RequiresSubscripionUserRoles []Role
	DefaultEnabledUserRoles      []Role
	Validate                     func(string) bool
}

NotificationEvent represents all possible notification events

type OAuthClaims

type OAuthClaims struct {
	OAuthID       string `json:"oauth/id"`
	OAuthProvider string `json:"oauth/provider"`
	OAuthName     string `json:"oauth/name"`
	OAuthEmail    string `json:"oauth/email"`
	jwt.StandardClaims
}

OAuthClaims represents what goes into temporary OAuth JWT tokens

type OriginalIdea added in v0.9.0

type OriginalIdea struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	Slug   string `json:"slug"`
	Status int    `json:"status"`
}

OriginalIdea holds details of the original idea of a duplicate

type Role added in v0.7.0

type Role int

Role is the role of a user inside a tenant

const (
	//RoleVisitor is the basic role for every user
	RoleVisitor Role = 1
	//RoleCollaborator has limited access to administrative console
	RoleCollaborator Role = 2
	//RoleAdministrator has full access to administrative console
	RoleAdministrator Role = 3
)

type SetResponse added in v0.5.0

type SetResponse struct {
	Number         int    `route:"number"`
	Status         int    `json:"status"`
	Text           string `json:"text"`
	OriginalNumber int    `json:"originalNumber"`
}

SetResponse represents the action to update an idea response

type SignInByEmail added in v0.6.0

type SignInByEmail struct {
	Email           string `json:"email" format:"lower"`
	VerificationKey string
}

SignInByEmail is the input model when user request to sign in by email

func (*SignInByEmail) GetEmail added in v0.9.0

func (e *SignInByEmail) GetEmail() string

GetEmail returns the email being verified

func (*SignInByEmail) GetKind added in v0.9.0

func (e *SignInByEmail) GetKind() EmailVerificationKind

GetKind returns EmailVerificationKindSignIn

func (*SignInByEmail) GetName added in v0.9.0

func (e *SignInByEmail) GetName() string

GetName returns empty for this kind of process

func (*SignInByEmail) GetUser added in v0.9.0

func (e *SignInByEmail) GetUser() *User

GetUser returns the current user performing this action

type SystemSettings added in v0.10.0

type SystemSettings struct {
	Mode            string `json:"mode"`
	BuildTime       string `json:"buildTime"`
	Version         string `json:"version"`
	Environment     string `json:"environment"`
	GoogleAnalytics string `json:"googleAnalytics"`
	Compiler        string `json:"compiler"`
	Domain          string `json:"domain"`
	HasLegal        bool   `json:"hasLegal"`
}

SystemSettings is the system-wide settings

type Tag added in v0.8.0

type Tag struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Slug     string `json:"slug"`
	Color    string `json:"color"`
	IsPublic bool   `json:"isPublic"`
}

Tag represents a simple tag

type Tenant

type Tenant struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	Subdomain      string `json:"subdomain"`
	Invitation     string `json:"invitation"`
	WelcomeMessage string `json:"welcomeMessage"`
	CNAME          string `json:"cname"`
	Status         int    `json:"-"`
	IsPrivate      bool   `json:"isPrivate"`
	LogoID         int    `json:"logoId"`
	CustomCSS      string `json:"-"`
}

Tenant represents a tenant

type UpdateIdea added in v0.8.0

type UpdateIdea struct {
	Number      int    `route:"number"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

UpdateIdea represents a request to edit an existing idea

type UpdateTenantAdvancedSettings added in v0.13.0

type UpdateTenantAdvancedSettings struct {
	CustomCSS string `json:"customCSS"`
}

UpdateTenantAdvancedSettings is the input model used to update tenant advanced settings

type UpdateTenantPrivacy added in v0.12.0

type UpdateTenantPrivacy struct {
	IsPrivate bool `json:"isPrivate"`
}

UpdateTenantPrivacy is the input model used to update tenant privacy settings

type UpdateTenantSettings added in v0.5.0

type UpdateTenantSettings struct {
	Title          string                    `json:"title"`
	Invitation     string                    `json:"invitation"`
	WelcomeMessage string                    `json:"welcomeMessage"`
	CNAME          string                    `json:"cname" format:"lower"`
}

UpdateTenantSettings is the input model used to update tenant general settings

type UpdateTenantSettingsLogo struct {
	Upload *UpdateTenantSettingsLogoUpload `json:"upload"`
	Remove bool                            `json:"remove"`
}

UpdateTenantSettingsLogo is the input model used to update logo

type UpdateTenantSettingsLogoUpload added in v0.13.0

type UpdateTenantSettingsLogoUpload struct {
	ContentType string `json:"contentType"`
	Content     []byte `json:"content"`
}

UpdateTenantSettingsLogoUpload is the input model used to uploade a new logo

type UpdateUserSettings added in v0.6.0

type UpdateUserSettings struct {
	Name     string            `json:"name"`
	Settings map[string]string `json:"settings"`
}

UpdateUserSettings is the model used to update user's settings

type Upload added in v0.13.0

type Upload struct {
	ContentType string `db:"content_type"`
	Size        int    `db:"size"`
	Content     []byte `db:"file"`
}

Upload represents a file that has been uploaded to Fider

type User

type User struct {
	ID        int             `json:"id"`
	Name      string          `json:"name"`
	Email     string          `json:"-"`
	Tenant    *Tenant         `json:"-"`
	Role      Role            `json:"role"`
	Providers []*UserProvider `json:"-"`
	Status    int             `json:"status"`
}

User represents an user inside our application

func (*User) HasProvider

func (u *User) HasProvider(provider string) bool

HasProvider returns true if current user has registered with given provider

func (*User) IsAdministrator added in v0.7.0

func (u *User) IsAdministrator() bool

IsAdministrator returns true if user is administrator

func (*User) IsCollaborator added in v0.7.0

func (u *User) IsCollaborator() bool

IsCollaborator returns true if user has special permissions

type UserInvitation added in v0.12.0

type UserInvitation struct {
	Email           string
	VerificationKey string
}

UserInvitation is the model used to register an invite sent to an user

func (*UserInvitation) GetEmail added in v0.12.0

func (e *UserInvitation) GetEmail() string

GetEmail returns the invited user's email

func (*UserInvitation) GetKind added in v0.12.0

GetKind returns EmailVerificationKindUserInvitation

func (*UserInvitation) GetName added in v0.12.0

func (e *UserInvitation) GetName() string

GetName returns empty for this kind of process

func (*UserInvitation) GetUser added in v0.12.0

func (e *UserInvitation) GetUser() *User

GetUser returns the current user performing this action

type UserProvider

type UserProvider struct {
	Name string
	UID  string
}

UserProvider represents the relashionship between an User and an Authentication provide

Jump to

Keyboard shortcuts

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