models

package
v0.0.0-...-ca0f7d1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIdentityEmptyEmail     = errors.New("identity email can't be empty")
	ErrIdentityIncorrectEmail = errors.New("identity email is incorrect")
	ErrIdentityIncorrectType  = errors.New("identity type is incorrect")
)
View Source
var (
	ErrSessionIncorrectClientID = errors.New("client ID is incorrect")
)

Functions

func CheckAccountStatus

func CheckAccountStatus(accountStatus string) bool

func CheckAccountType

func CheckAccountType(accountType string) bool

func CheckClientID

func CheckClientID(clientID string) bool

func CheckIdentityStatus

func CheckIdentityStatus(status string) bool

func CheckIdentityType

func CheckIdentityType(identityType string) bool

func CheckTokenType

func CheckTokenType(tokenType string) bool

Types

type Account

type Account struct {
	ID            uuid.UUID     `json:"-"`
	AccountStatus AccountStatus `json:"-"`
	AccountType   AccountType   `json:"-"`
	AccountName   string        `json:"-"`
	Profile       Profile       `json:"-"`
	Settings      Settings      `json:"-"`
	LastIP        string        `json:"-"`
	LastLogin     time.Time     `json:"-"`
	CreatedAt     time.Time     `json:"-"`
	UpdatedAt     time.Time     `json:"-"`
}

func (*Account) SetAccountStatus

func (a *Account) SetAccountStatus(accountStatus AccountStatus)

func (*Account) SetAccountType

func (a *Account) SetAccountType(accountType AccountType)

type AccountStatus

type AccountStatus string
const (
	AccountStatusUnconfirmed AccountStatus = "unconfirmed"
	AccountStatusConfirmed   AccountStatus = "confirmed"
	AccountStatusDeleted     AccountStatus = "deleted"
	AccountStatusBanned      AccountStatus = "banned"
)

func (AccountStatus) String

func (a AccountStatus) String() string

type AccountType

type AccountType string
const (
	AccountTypeFree       AccountType = "free"
	AccountTypeCommercial AccountType = "commercial"
)

func (AccountType) String

func (a AccountType) String() string

type ClientID

type ClientID string
const (
	ClientIDWEB           ClientID = "web"
	ClientIDNativeAndroid ClientID = "native_android"
	ClientIDNativeIOS     ClientID = "native_ios"
)

func (ClientID) String

func (c ClientID) String() string

type EmailNotificationScopeType

type EmailNotificationScopeType string
const (
	// Auth confirm, change email and so on
	EmailNotificationScopeTypeBase EmailNotificationScopeType = "base"
	// Reminders about started challenges
	EmailNotificationScopeTypeReminders EmailNotificationScopeType = "reminders"
	// News about new challenges, new achievements
	EmailNotificationScopeTypeNews EmailNotificationScopeType = "news"
)

func (EmailNotificationScopeType) String

type EmailNotifications

type EmailNotifications struct {
	Email string                       `json:"-"`
	Scope []EmailNotificationScopeType `json:"-"`
}

type File

type File struct {
	ID               uuid.UUID            `json:"-"`
	LinkedEntityID   uuid.UUID            `json:"-"`
	LinkedEntityType LinkedEntityType     `json:"-"`
	AuthorID         uuid.UUID            `json:"-"`
	ModerationStatus FileModerationStatus `json:"-"`
	Name             string               `json:"-"`
	Extensions       []string             `json:"-"`
	Description      string               `json:"-"`
	Size             int                  `json:"-"`
	Copyright        string               `json:"-"`
}

func GetAccountAvatarFileFromFiles

func GetAccountAvatarFileFromFiles(files []File) File

func ParseFileFromBytes

func ParseFileFromBytes(rawFile []byte) (*File, error)

func (*File) ConvertToMap

func (f *File) ConvertToMap(prefix string) map[string]interface{}

func (*File) GetFileNames

func (f *File) GetFileNames() []string

func (*File) IsDefined

func (f *File) IsDefined() bool

type FileModerationStatus

type FileModerationStatus string
const (
	FileModerationStatusRejected   FileModerationStatus = "rejected"
	FileModerationStatusInProgress FileModerationStatus = "in_progress"
	FileModerationStatusApproved   FileModerationStatus = "approved"
	FileModerationStatusNotStarted FileModerationStatus = "not_started"
)

func (FileModerationStatus) String

func (f FileModerationStatus) String() string

type Identity

type Identity struct {
	ID               uuid.UUID      `json:"-"`
	AccountID        uuid.UUID      `json:"-"`
	IdentityType     IdentityType   `json:"-"`
	IdentityStatus   IdentityStatus `json:"-"`
	GoogleSocialID   string         `json:"-"`
	FacebookSocialID string         `json:"-"`
	Email            string         `json:"-"`
	PasswordHash     string         `json:"-"`
	CreatedAt        time.Time      `json:"-"`
	UpdatedAt        time.Time      `json:"-"`
}

func (*Identity) SetEmail

func (i *Identity) SetEmail(email string) error

SetEmail set email to User model

func (*Identity) SetIdentityStatus

func (i *Identity) SetIdentityStatus(status IdentityStatus)

func (*Identity) SetIdentityType

func (i *Identity) SetIdentityType(identityType IdentityType)

type IdentityStatus

type IdentityStatus string
const (
	IdentityStatusUnconfirmed IdentityStatus = "unconfirmed"
	IdentityStatusConfirmed   IdentityStatus = "confirmed"
)

func (IdentityStatus) String

func (i IdentityStatus) String() string

type IdentityType

type IdentityType string
const (
	IdentityTypeEmail    IdentityType = "email"
	IdentityTypeFacebook IdentityType = "facebook"
	IdentityTypeGoogle   IdentityType = "google"
)

func (IdentityType) String

func (i IdentityType) String() string

type LinkedEntityType

type LinkedEntityType string
const (
	LinkedEntityTypeAccountAvatar LinkedEntityType = "account_avatar"
)

func (LinkedEntityType) String

func (l LinkedEntityType) String() string

type MonthlyStats

type MonthlyStats struct {
	ID                uuid.UUID
	ChallengerID      uuid.UUID
	StartedChallenges int
	AchivedChallenges int
	CreatedChallenges int
	FinishedTasks     int
	Posts             int
	Feedbacks         int
	Month             int
	Year              int
}

type MonthlyStatsType

type MonthlyStatsType string
const (
	MonthlyStatsTypeAcceptedChallenges MonthlyStatsType = "acceptedChallenges"
	MonthlyStatsTypeAchivedChallenges  MonthlyStatsType = "achivedChallenges"
	MonthlyStatsTypeCreatedChallenges  MonthlyStatsType = "createdChallenges"
	MonthlyStatsTypeFinishedTasks      MonthlyStatsType = "finishedTasks"
	MonthlyStatsTypePosts              MonthlyStatsType = "posts"
	MonthlyStatsTypeFeedbacks          MonthlyStatsType = "feedbacks"
)

type Notifications

type Notifications struct {
	Email EmailNotifications `json:"-"`
}

type Profile

type Profile struct {
	FirstName   string       `json:"-"`
	LastName    string       `json:"-"`
	Country     string       `json:"-"`
	City        string       `json:"-"`
	Gender      string       `json:"-"`
	Birthday    time.Time    `json:"-"`
	Description string       `json:"-"`
	SocialLinks []SocialLink `json:"-"`
	AvatarURL   string       `json:"-"`
	Interests   []string     `json:"-"`
}

type Session

type Session struct {
	ID                      uuid.UUID
	AccountID               uuid.UUID
	IdentityID              uuid.UUID
	ClientID                ClientID
	AccessToken             uuid.UUID
	AccessTokenExpiresDate  time.Time
	RefreshToken            uuid.UUID
	RefreshTokenExpiresDate time.Time
}

type SessionTokens

type SessionTokens struct {
	AccessToken  string
	RefreshToken string
}

type Settings

type Settings struct {
	Notifications Notifications `json:"-"`
}
type SocialLink struct {
	Type SocialLinkType
	URL  string
}

type SocialLinkType

type SocialLinkType string
const (
	SocialLinkTypeFacebook  SocialLinkType = "facebook"
	SocialLinkTypeGoogle    SocialLinkType = "google"
	SocialLinkTypeInstagram SocialLinkType = "instagram"
	SocialLinkTypeTwitter   SocialLinkType = "twitter"
)

func (SocialLinkType) String

func (s SocialLinkType) String() string

type SocialNetworkType

type SocialNetworkType string
const (
	SocialNetworkTypeGoogle   SocialNetworkType = "google"
	SocialNetworkTypeFacebook SocialNetworkType = "facebook"
)

type Token

type Token struct {
	ID          uuid.UUID
	TokenType   TokenType
	TokenStatus TokenStatus
	AccountID   uuid.UUID
	IdentityID  uuid.UUID
	ClientID    ClientID
	ExpiresDate time.Time
}

type TokenStatus

type TokenStatus string
const (
	TokenStatusActive TokenStatus = "active"
	TokenStatusUsed   TokenStatus = "used"
)

func (TokenStatus) String

func (t TokenStatus) String() string

type TokenType

type TokenType string
const (
	TokenTypeRegistrationConfirmation TokenType = "registration_confirmation"
	TokenTypeEmailConfirmation        TokenType = "email_confirmation"
	TokenTypeAutoLogin                TokenType = "auto_login"
)

func (TokenType) String

func (t TokenType) String() string

type User

type User struct {
	ID            uuid.UUID
	AccountType   AccountType
	AccountStatus AccountStatus
	AccountName   string
	Profile       Profile
	Identities    []UserIdentity
	LastIP        string
	LastLogin     time.Time
	CreatedAt     time.Time
	UpdatedAt     time.Time
	Settings      Settings
	UserType      UserType
	AvatarFile    File
	MediaPrefix   string
}

func NewUser

func NewUser(
	userType UserType,
	account Account,
	identities []*Identity,
) User

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

type UserIdentity

type UserIdentity struct {
	IdentityType   IdentityType
	Email          string
	IdentityStatus IdentityStatus
}

type UserType

type UserType string
const (
	UserTypeFull  UserType = "full"
	UserTypeShort UserType = "short"
)

Jump to

Keyboard shortcuts

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