model

package
v0.0.0-...-224a6a0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACCESS_TOKEN_EXPIRATION                     = time.Duration(24*365) * time.Hour
	CONTEXT_SESSION_KEY     internal.ContextKey = "auth:session"
	CONTEXT_USER_KEY        internal.ContextKey = "auth:user"
)
View Source
const (
	COMMUNITY_ADDRESS_MAX_LENGTH = 100
	COMMUNITY_ADDRESS_MIN_LENGTH = 1
	COMMUNITY_NAME_MAX_LENGTH    = 100
	COMMUNITY_NAME_MIN_LENGTH    = 1
)
View Source
const (
	MEMBERSHIP_DOOR_MAX_LENGTH = 25
	MEMBERSHIP_DOOR_MIN_LENGTH = 0
)
View Source
const (
	OTP_CODE_LENGTH  = 6
	OTP_MAX_ATTEMPTS = 5
	OTP_EXPIRATION   = time.Duration(5) * time.Minute
)
View Source
const (
	POST_MESSAGE_MAX_LENGTH = 280
	POST_MESSAGE_MIN_LENGTH = 1

	POST_POLL_WIDGET_MAX_OPTIONS = 5
	POST_POLL_WIDGET_MIN_OPTIONS = 2

	POST_POLL_WIDGET_MAX_OPTION_LENGTH = 100
	POST_POLL_WIDGET_MIN_OPTION_LENGTH = 1
)
View Source
const (
	USER_NAME_MAX_LENGTH = 100
	USER_NAME_MIN_LENGTH = 1
	USER_DEFAULT_PICTURE = "https://eu.ui-avatars.com/api/?name=%s&size=128"
)
View Source
const (
	INVITATION_EXPIRATION = time.Duration(24*30) * time.Hour
)

Variables

View Source
var (
	COMMUNITY_DEFAULT_CATEGORIES = []string{
		"Suministros",
		"Desagües",
		"Cerrajería",
		"Ascensor",
		"Estructural",
		"Zonas Comunes",
		"Otros",
	}
)
View Source
var MembershipRole = struct {
	ADMINISTRATOR string
	PRESIDENT     string
	SECRETARY     string
	RESIDENT      string
	LESSEE        string
	Has           func(role string) bool
}{"ADMINISTRATOR", "PRESIDENT", "SECRETARY", "RESIDENT", "LESSEE",
	func(role string) bool {
		return role == "ADMINISTRATOR" || role == "PRESIDENT" ||
			role == "SECRETARY" || role == "RESIDENT" || role == "LESSEE"
	},
}
View Source
var OTPType = struct {
	SMS   string
	EMAIL string
	Has   func(typee string) bool
}{"SMS", "EMAIL", func(typee string) bool {
	return typee == "SMS" || typee == "EMAIL"
}}
View Source
var PostState = struct {
	PENDING     string
	IN_PROGRESS string
	REJECTED    string
	ACCEPTED    string
	RESOLVED    string
	Has         func(role string) bool
}{"PENDING", "IN_PROGRESS", "REJECTED", "ACCEPTED", "RESOLVED",
	func(role string) bool {
		return role == "PENDING" || role == "IN_PROGRESS" ||
			role == "REJECTED" || role == "ACCEPTED" || role == "RESOLVED"
	},
}
View Source
var PostType = struct {
	PUBLICATION string
	ISSUE       string
	EVENT       string
	Has         func(typee string) bool
}{"PUBLICATION", "ISSUE", "EVENT", func(typee string) bool {
	return typee == "PUBLICATION" || typee == "ISSUE" || typee == "EVENT"
}}

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	class.Model
	Private AccessTokenPrivate
	Public  AccessTokenPublic
}

func NewAccessToken

func NewAccessToken() *AccessToken

func (*AccessToken) Copy

func (self *AccessToken) Copy() *AccessToken

func (AccessToken) String

func (self AccessToken) String() string

type AccessTokenPrivate

type AccessTokenPrivate struct {
	SessionID string    `json:"session_id"`
	CreatedAt time.Time `json:"created_at"`
	// Redundant field in order not to hit the DB to validate session expiration
	ExpiresAt time.Time `json:"expires_at"`
}

func (*AccessTokenPrivate) Valid

func (self *AccessTokenPrivate) Valid() error

Needed for Paseto library (Validation will be performed in the usecase)

type AccessTokenPublic

type AccessTokenPublic struct {
	ApiVersion string `json:"api_version"`
}

type Community

type Community struct {
	class.Model
	ID         string     `db:"id"`
	Address    string     `db:"address"`
	Name       string     `db:"name"`
	Categories []string   `db:"categories"`
	PinnedIDs  []string   `db:"pinned_ids"`
	CreatedAt  time.Time  `db:"created_at"`
	DeletedAt  *time.Time `db:"deleted_at"`
}

func NewCommunity

func NewCommunity() *Community

func (*Community) Copy

func (self *Community) Copy() *Community

func (Community) String

func (self Community) String() string

type Invitation

type Invitation struct {
	class.Model
	ID          string    `db:"id"`
	Phone       string    `db:"phone"`
	CommunityID string    `db:"community_id"`
	Door        string    `db:"door"`
	Role        string    `db:"role"`
	CreatedAt   time.Time `db:"created_at"`
	RemindedAt  time.Time `db:"reminded_at"`
	ExpiresAt   time.Time `db:"expires_at"`
}

func NewInvitation

func NewInvitation() *Invitation

func (*Invitation) Copy

func (self *Invitation) Copy() *Invitation

func (Invitation) String

func (self Invitation) String() string

type Membership

type Membership struct {
	class.Model
	ID          string     `db:"id"`
	UserID      string     `db:"user_id"`
	CommunityID string     `db:"community_id"`
	Door        string     `db:"door"`
	Role        string     `db:"role"`
	CreatedAt   time.Time  `db:"created_at"`
	DeletedAt   *time.Time `db:"deleted_at"`
}

func NewMembership

func NewMembership() *Membership

func (*Membership) Copy

func (self *Membership) Copy() *Membership

func (Membership) String

func (self Membership) String() string

type OTP

type OTP struct {
	class.Model
	ID        string    `db:"id"`
	Asset     string    `db:"asset"`
	Type      string    `db:"type"`
	Code      string    `db:"code"`
	Attempts  int       `db:"attempts"`
	ExpiresAt time.Time `db:"expires_at"`
}

func NewOTP

func NewOTP() *OTP

func (*OTP) Copy

func (self *OTP) Copy() *OTP

func (OTP) String

func (self OTP) String() string

type Post

type Post struct {
	class.Model
	ID            string    `db:"id"`
	ThreadID      *string   `db:"thread_id"`
	CreatorID     string    `db:"creator_id"`
	LastHistoryID *string   `db:"last_history_id"`
	Type          string    `db:"type"`
	Priority      *int      `db:"priority"`
	RecipientIDs  *[]string `db:"recipient_ids"`
	VoterIDs      []string  `db:"voter_ids"`
	CreatedAt     time.Time `db:"created_at"`
}

func NewPost

func NewPost() *Post

func (*Post) Copy

func (self *Post) Copy() *Post

func (Post) String

func (self Post) String() string

type PostHistory

type PostHistory struct {
	class.Model
	ID         string      `db:"id"`
	PostID     string      `db:"post_id"`
	UpdatorID  string      `db:"updator_id"`
	Message    string      `db:"message"`
	Categories []string    `db:"categories"`
	State      *string     `db:"state"`
	Media      []string    `db:"media"`
	Widgets    PostWidgets `db:"widgets"`
	CreatedAt  time.Time   `db:"created_at"`
}

func NewPostHistory

func NewPostHistory() *PostHistory

func (*PostHistory) Copy

func (self *PostHistory) Copy() *PostHistory

func (PostHistory) String

func (self PostHistory) String() string

type PostWidgets

type PostWidgets struct {
	Poll *map[string][]string
}

type Session

type Session struct {
	class.Model
	ID         string          `db:"id"`
	UserID     string          `db:"user_id"`
	Metadata   SessionMetadata `db:"metadata"`
	CreatedAt  time.Time       `db:"created_at"`
	LastSeenAt time.Time       `db:"last_seen_at"`
	ExpiredAt  *time.Time      `db:"expired_at"`
}

func NewSession

func NewSession() *Session

func (*Session) Copy

func (self *Session) Copy() *Session

func (Session) String

func (self Session) String() string

type SessionMetadata

type SessionMetadata struct {
	IP         string
	Device     string
	ApiVersion string
}

type User

type User struct {
	class.Model
	ID            string     `db:"id"`
	Phone         string     `db:"phone"`
	Name          string     `db:"name"`
	Email         string     `db:"email"`
	Picture       string     `db:"picture"`
	Birthday      date.Date  `db:"birthday"`
	Language      string     `db:"language"`
	LastSessionID *string    `db:"last_session_id"`
	IsBanned      bool       `db:"is_banned"`
	CreatedAt     time.Time  `db:"created_at"`
	DeletedAt     *time.Time `db:"deleted_at"`
}

func NewUser

func NewUser() *User

func (*User) Copy

func (self *User) Copy() *User

func (User) String

func (self User) String() string

Jump to

Keyboard shortcuts

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