model

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EMAIL_DELIVER_BASEURL                = "https://email.illasoft.com/v1/"
	EMAIL_DELIVER_USAGE_SUBSCRIBE        = "subscribe"
	EMAIL_DELIVER_USAGE_VERIFICATIONCODE = "code"
	EMAIL_DELIVER_INVITE_EMAIL           = "invite"
	EMAIL_DELIVER_SHARE_APP_EMAIL        = "shareApp"
)
View Source
const CATEGORY_INVITE_BY_EMAIL = 2
View Source
const CATEGORY_INVITE_BY_LINK = 1

invite record category

View Source
const CUSTOMIZATION_LANGUAGE_EN_US = "en-US"
View Source
const CUSTOMIZATION_LANGUAGE_ZH_CN = "zh-CN"
View Source
const INVITE_EMAIL_AND_SHARE_APP_TEMPLATE = "&teamIdentifier=%s&email=%s&appID=%s"
View Source
const INVITE_EMAIL_TEMPLATE = "&teamIdentifier=%s&email=%s"
View Source
const INVITE_RECORD_STATUS_OK = 1

invite record status

View Source
const INVITE_SHARE_APP_TEMPLATE = "&teamIdentifier=%s&appID=%s"
View Source
const INVITE_URI_TEMPLATE = "?inviteToken=%s"
View Source
const PENDING_USER_AVATAR = ""
View Source
const PENDING_USER_ID = 0
View Source
const PENDING_USER_NICKNAME = "pending"
View Source
const PENDING_USER_PASSWORDDIGEST = "pending"
View Source
const TEAM_DEFAULT_ID = 0
View Source
const TEAM_FIELD_ICON = "icon"
View Source
const TEAM_FIELD_IDENTIFIER = "identifier"
View Source
const TEAM_FIELD_NAME = "name"
View Source
const TEAM_FOLDER_PREFIX = "team-"
View Source
const TEAM_ICON_FOLDER = "/icon"
View Source
const TEAM_MEMBER_STATUS_OK = 1
View Source
const TEAM_MEMBER_STATUS_PENDING = 2
View Source
const TEAM_P_FIELD_ALLOW_EDITOR_INVITE = "allowEditorInvite"
View Source
const TEAM_P_FIELD_ALLOW_EDITOR_MANAGE_TEAM_MEMBER = "allowEditorManageTeamMember"
View Source
const TEAM_P_FIELD_ALLOW_VIEWER_INVITE = "allowViewerInvite"
View Source
const TEAM_P_FIELD_ALLOW_VIEWER_MANAGE_TEAM_MEMBER = "allowViewerManageTeamMember"
View Source
const TEAM_P_FIELD_INVITE_LINK_ENABLED = "inviteLinkEnabled"
View Source
const TEAM_SPACE_FOLDER = "/team"
View Source
const TEAM_SYSTEM_FOLDER = "/system"
View Source
const USER_AVATAR_FOLVER = "/avatar"
View Source
const USER_FOLDER_PREFIX = "user-"

Variables

View Source
var Config *config.Config

Functions

func BuildLookUpTableForInvitesExport

func BuildLookUpTableForInvitesExport(invites []*Invite) map[int]*InviteForExport

func BuildLookUpTableForUserExport

func BuildLookUpTableForUserExport(users []*User) map[int]*UserForExport

func BuildTeamIDLookUpTableForTeamMemberExport

func BuildTeamIDLookUpTableForTeamMemberExport(teamMembers []*TeamMember) map[int]*TeamMemberForExport

func CreateAccessToken

func CreateAccessToken(id int, uid uuid.UUID) (string, error)

func ExtractUserIDFromToken

func ExtractUserIDFromToken(accessToken string) (int, uuid.UUID, error)

func GenerateAndSendVerificationCode

func GenerateAndSendVerificationCode(email, usage string) (string, error)

func PickUpTeamIDsInTeamMembers

func PickUpTeamIDsInTeamMembers(teamMembers []*TeamMember) []int

func PickUpTeamMemberIDsInTeamMembers

func PickUpTeamMemberIDsInTeamMembers(teamMembers []*TeamMember) []int

func PickUpUserIDsInUserMembers

func PickUpUserIDsInUserMembers(teamMembers []*TeamMember) []int

func SendInviteEmail

func SendInviteEmail(m *EmailInviteMessage) error

func SendShareAppEmail

func SendShareAppEmail(m *EmailShareAppMessage) error

func SendSubscriptionEmail

func SendSubscriptionEmail(email string) error

func SendVerificationEmail

func SendVerificationEmail(email, code, usage string) error

func ValidateAccessToken

func ValidateAccessToken(accessToken string) (bool, error)

func ValidateVerificationCode

func ValidateVerificationCode(vCode, codeToken, email, usage string) (bool, error)

Types

type AuthClaims

type AuthClaims struct {
	User   int       `json:"user"`
	UID    uuid.UUID `json:"uuid"`
	Random string    `json:"rnd"`
	jwt.RegisteredClaims
}

type ChangePasswordRequest

type ChangePasswordRequest struct {
	CurrentPassword string `json:"currentPassword" validate:"required"`
	NewPassword     string `json:"newPassword" validate:"required"`
}

func NewChangePasswordRequest

func NewChangePasswordRequest() *ChangePasswordRequest

type ConfigInviteLinkRequest

type ConfigInviteLinkRequest struct {
	InviteLinkEnabled bool `json:"inviteLinkEnabled"`
}

func NewConfigInviteLinkRequest

func NewConfigInviteLinkRequest() *ConfigInviteLinkRequest

type CreateDomainRequest

type CreateDomainRequest struct {
	TeamID             int    `json:"team_id" gorm:"column:team_id;type:bigserial;index:domains_team_id"`
	UserDomain         string `json:"user_domain" gorm:"column:user_domain;type:varchar;size:255;not null"`
	SystemDomainPrefix string `json:"system_domain_prefix" gorm:"column:system_domain_prefix;type:varchar;size:255;not null"`
	ResolveStatus      int    `json:"resolve_status" gorm:"column:resolve_status;type:smallint;"`
	Category           int    `json:"category" gorm:"column:category;type:smallint;"`
}

func NewCreateDomainRequest

func NewCreateDomainRequest() *CreateDomainRequest

type CreateInvitationCodeRequest

type CreateInvitationCodeRequest struct {
	TeamID        int `json:"teamID" gorm:"column:team_id;type:bigserial;index:invitation_code_team_id"`
	ConsumeStatus int `json:"consumeStatus" gorm:"column:consume_status;type:smallint;"`
}

func NewCreateInvitationCodeRequest

func NewCreateInvitationCodeRequest() *CreateInvitationCodeRequest

type CreateInviteRequest

type CreateInviteRequest struct {
	TeamID       int    `json:"teamID" gorm:"column:team_id;type:bigserial;index:users_ukey"`
	Email        string `json:"email" gorm:"column:email;type:varchar;size:255;;index:invite_email"`
	UserRole     int    `json:"userRole" gorm:"column:user_role;type:smallint;index:invite_user_role"`
	InviteStatus int    `json:"inviteStatus" gorm:"column:invite_status;type:smallint;index:users_ukey"`
}

func NewCreateInviteRequest

func NewCreateInviteRequest() *CreateInviteRequest

type CreateTeamMemberRequest

type CreateTeamMemberRequest struct {
	TeamID     int    `json:"teamID" gorm:"column:team_id;type:bigserial;index:team_members_team_and_user_id"`
	UserID     int    `json:"userID" gorm:"column:user_id;type:bigserial;index:team_members_team_and_user_id"`
	UserRole   int    `json:"userRole" gorm:"column:user_role;type:smallint"`
	Permission string `json:"permission" gorm:"column:authority;type:jsonb"` // for user permission config
}

func NewCreateTeamMemberRequest

func NewCreateTeamMemberRequest() *CreateTeamMemberRequest

type CreateTeamRequest

type CreateTeamRequest struct {
	Name           string    `json:"name" validate:"required"`
	TeamDomain     string    `json:"teamDomain"`
	Identifier     string    `json:"identifier" validate:"required"`
	InvitationCode uuid.UUID `json:"invitationCode" validate:"required"`
}

func NewCreateTeamRequest

func NewCreateTeamRequest() *CreateTeamRequest

func (CreateTeamRequest) ExportIdentifier

func (req CreateTeamRequest) ExportIdentifier() string

func (CreateTeamRequest) ExportInvitationCodeInUUID

func (req CreateTeamRequest) ExportInvitationCodeInUUID() uuid.UUID

func (CreateTeamRequest) ExportName

func (req CreateTeamRequest) ExportName() string

func (CreateTeamRequest) ExportTeamDomain

func (req CreateTeamRequest) ExportTeamDomain() string

type CreateUserRequest

type CreateUserRequest struct {
	Nickname       string `json:"nickname" gorm:"column:nickname;type:varchar;size:15;not null"`
	PasswordDigest string `json:"passworddigest" gorm:"column:password_digest;type:varchar;size:60;not null"`
	Email          string `json:"email" gorm:"column:email;type:varchar;size:255;not null"`
	SSOConfig      string `json:"SSOConfig" gorm:"column:sso_config;type:jsonb"`        // for single sign-on data
	Customization  string `json:"customization" gorm:"column:customization;type:jsonb"` // for user itself customization config, including: Language, IsSubscribed

}

func NewCreateUserRequest

func NewCreateUserRequest() *CreateUserRequest

type CreateUserResponse

type CreateUserResponse struct {
	ID string `json:"id"`
}

func NewCreateUserResponse

func NewCreateUserResponse(id int) *CreateUserResponse

func (*CreateUserResponse) ExportForFeedback

func (resp *CreateUserResponse) ExportForFeedback() interface{}

type Drive

type Drive struct {
	SystemDriveS3Instance S3Instance
	TeamDriveS3Instance   S3Instance
	// contains filtered or unexported fields
}

func NewDrive

func NewDrive(systemDriveS3Instance S3Instance, teamDriveS3Instance S3Instance, logger *zap.SugaredLogger) *Drive

type EmailInviteMessage

type EmailInviteMessage struct {
	UserName      string `json:"userName"`
	TeamName      string `json:"teamName"`
	TeamIcon      string `json:"teamIcon"`
	Email         string `json:"email"`
	JoinLink      string `json:"joinLink"`
	Language      string `json:"language"`
	ValidateToken string `json:"validateToken"` // token for query authorize, base64.Encoding(md5(...param + ROTOR_TOKEN))
}

func NewEmailInviteMessage

func NewEmailInviteMessage(invite *Invite, team *Team, user *User) *EmailInviteMessage

func (*EmailInviteMessage) Export

func (m *EmailInviteMessage) Export() map[string]string

func (*EmailInviteMessage) SetValidateToken

func (m *EmailInviteMessage) SetValidateToken(token string)

type EmailShareAppMessage

type EmailShareAppMessage struct {
	UserName      string `json:"userName"`
	TeamName      string `json:"teamName"`
	TeamIcon      string `json:"teamIcon"`
	Email         string `json:"email"`
	AppLink       string `json:"appLink"`
	Language      string `json:"language"`
	ValidateToken string `json:"validateToken"` // token for query authorize, base64.Encoding(md5(...param + ROTOR_TOKEN))
}

func NewEmailShareAppMessage

func NewEmailShareAppMessage(invite *Invite, team *Team, user *User) *EmailShareAppMessage

func (*EmailShareAppMessage) Export

func (m *EmailShareAppMessage) Export() map[string]string

func (*EmailShareAppMessage) SetValidateToken

func (m *EmailShareAppMessage) SetValidateToken(token string)

type ForgetPasswordRequest

type ForgetPasswordRequest struct {
	Email             string `json:"email" validate:"required"`
	NewPassword       string `json:"newPassword" validate:"required"`
	VerificationCode  string `json:"verificationCode" validate:"required"`
	VerificationToken string `json:"verificationToken" validate:"required"`
}

func NewForgetPasswordRequest

func NewForgetPasswordRequest() *ForgetPasswordRequest

type GenerateInviteLinkResponse

type GenerateInviteLinkResponse struct {
	TeamID     string `json:"teamID"`
	AppID      string `json:"appID"`
	UserRole   int    `json:"userRole"`
	InviteLink string `json:"inviteLink"`
}

func NewGenerateInviteLinkResponse

func NewGenerateInviteLinkResponse() *GenerateInviteLinkResponse

func NewGenerateInviteLinkResponseByInvite

func NewGenerateInviteLinkResponseByInvite(invite *Invite) *GenerateInviteLinkResponse

func (*GenerateInviteLinkResponse) ExportForFeedback

func (resp *GenerateInviteLinkResponse) ExportForFeedback() interface{}

func (*GenerateInviteLinkResponse) SetAppID

func (u *GenerateInviteLinkResponse) SetAppID(appID int)
func (u *GenerateInviteLinkResponse) SetInviteLink(inviteLink string)

func (*GenerateInviteLinkResponse) SetTeamID

func (u *GenerateInviteLinkResponse) SetTeamID(teamID int)

func (*GenerateInviteLinkResponse) SetUserRole

func (u *GenerateInviteLinkResponse) SetUserRole(userRole int)

type GetAllTeamMembersResponse

type GetAllTeamMembersResponse struct {
	AllTeamMembers []*TeamMemberWithUserInfoForExportConverted
}

func (*GetAllTeamMembersResponse) ExportForFeedback

func (resp *GetAllTeamMembersResponse) ExportForFeedback() interface{}

type GetMyTeamsResponse

type GetMyTeamsResponse struct {
	MyTeams []*MyTeam
}

func NewGetMyTeamsResponse

func NewGetMyTeamsResponse(teams []*Team, teamMembersLT map[int]*TeamMemberForExport) *GetMyTeamsResponse

func (*GetMyTeamsResponse) ExportForFeedback

func (resp *GetMyTeamsResponse) ExportForFeedback() interface{}

type GetTargetTeamByInternalRequestResponse

type GetTargetTeamByInternalRequestResponse struct {
	ID         string    `json:"id"`
	UID        uuid.UUID `json:"uid"`
	Name       string    `json:"name"`
	Identifier string    `json:"identifier"`
	Icon       string    `json:"icon"`
	Permission string    `json:"permission"` // for team permission config
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

func NewGetTargetTeamByInternalRequestResponse

func NewGetTargetTeamByInternalRequestResponse(team *Team) *GetTargetTeamByInternalRequestResponse

func (*GetTargetTeamByInternalRequestResponse) ExportForFeedback

func (resp *GetTargetTeamByInternalRequestResponse) ExportForFeedback() interface{}

type GetTargetUserByInternalRequestResponse

type GetTargetUserByInternalRequestResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewGetTargetUserByInternalRequestResponse

func NewGetTargetUserByInternalRequestResponse(user *User) *GetTargetUserByInternalRequestResponse

func (*GetTargetUserByInternalRequestResponse) ExportForFeedback

func (resp *GetTargetUserByInternalRequestResponse) ExportForFeedback() interface{}

func (*GetTargetUserByInternalRequestResponse) SetTeamMemberID

func (resp *GetTargetUserByInternalRequestResponse) SetTeamMemberID(id int)

type GetTeamByTeamIDResponse

type GetTeamByTeamIDResponse struct {
	ID         string          `json:"id"`
	UID        uuid.UUID       `json:"uid"`
	Name       string          `json:"name"`
	Identifier string          `json:"identifier"`
	Icon       string          `json:"icon"`
	Permission *TeamPermission `json:"permission"`
	CreatedAt  time.Time       `json:"createdAt"`
	UpdatedAt  time.Time       `json:"updatedAt"`
}

func NewGetTeamByTeamIDResponse

func NewGetTeamByTeamIDResponse(t *Team) *GetTeamByTeamIDResponse

func (*GetTeamByTeamIDResponse) ExportForFeedback

func (resp *GetTeamByTeamIDResponse) ExportForFeedback() interface{}

type GetTeamMemberResponse

type GetTeamMemberResponse struct {
	ID           string                `json:"userID"`
	UID          uuid.UUID             `json:"uid"`
	TeamMemberID string                `json:"teamMemberID"`
	Nickname     string                `json:"nickname"`
	Email        string                `json:"email"`
	Avatar       string                `json:"avatar"`
	Language     string                `json:"language"`
	IsSubscribed bool                  `json:"isSubscribed"`
	UserRole     int                   `json:"userRole"`
	Permission   *TeamMemberPermission `json:"permission"` // for user permission config
	UserStatus   int                   `json:"userStatus"`
	CreatedAt    time.Time             `json:"createdAt"`
	UpdatedAt    time.Time             `json:"updatedAt"`
}

func (*GetTeamMemberResponse) ExportForFeedback

func (resp *GetTeamMemberResponse) ExportForFeedback() interface{}

type GetTeamPermissionResponse

type GetTeamPermissionResponse struct {
	AllowEditorInvite           bool `json:"allowEditorInvite"`
	AllowViewerInvite           bool `json:"allowViewerInvite"`
	AllowEditorManageTeamMember bool `json:"allowEditorManageTeamMember"`
	AllowViewerManageTeamMember bool `json:"allowViewerManageTeamMember"`
	InviteLinkEnabled           bool `json:"inviteLinkEnabled"`
}

func NewGetTeamPermissionResponse

func NewGetTeamPermissionResponse(team *Team) *GetTeamPermissionResponse

func (*GetTeamPermissionResponse) ExportForFeedback

func (resp *GetTeamPermissionResponse) ExportForFeedback() interface{}

type GetUserByIDResponse

type GetUserByIDResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewGetUserByIDResponse

func NewGetUserByIDResponse(user *User) *GetUserByIDResponse

func (*GetUserByIDResponse) ExportForFeedback

func (resp *GetUserByIDResponse) ExportForFeedback() interface{}

func (*GetUserByIDResponse) SetTeamMemberID

func (resp *GetUserByIDResponse) SetTeamMemberID(id int)

type GetVerificationCodeResponse

type GetVerificationCodeResponse struct {
	VerificationToken string `json:"verificationToken"`
}

func NewGetVerificationCodeResponse

func NewGetVerificationCodeResponse(token string) *GetVerificationCodeResponse

func (*GetVerificationCodeResponse) ExportForFeedback

func (resp *GetVerificationCodeResponse) ExportForFeedback() interface{}

type Invite

type Invite struct {
	ID             int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:invite_ukey"`
	UID            uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:invite_uid"`
	Category       int       `json:"category" gorm:"column:category;type:smallint;not null"`
	TeamID         int       `json:"teamID" gorm:"column:team_id;type:bigserial;index:users_ukey"`
	TeamMemberID   int       `json:"teamMemberID" gorm:"column:team_member_id;type:bigserial"`
	TeamIdentifier string    `json:"teamIdentifier" sql:"-" gorm:"-"`
	AppID          int       `json:"appID" sql:"-" gorm:"-"`
	Hosts          string    `json:"hosts" sql:"-" gorm:"-"`
	Email          string    `json:"email" gorm:"column:email;type:varchar;size:255;;index:invite_email"`
	EmailStatus    bool      `json:"emailStatus" gorm:"column:email_status;type:bool"`
	UserRole       int       `json:"userRole" gorm:"column:user_role;type:smallint;index:invite_user_role"`
	Status         int       `json:"status" gorm:"column:status;type:smallint;index:users_ukey"`
	CreatedAt      time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt      time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewInvite

func NewInvite() *Invite

func NewInviteByCreateInviteRequest

func NewInviteByCreateInviteRequest(req *CreateInviteRequest) *Invite

func NewInviteByUpdateInviteRequest

func NewInviteByUpdateInviteRequest(req *UpdateInviteRequest) *Invite

func NewInviteEmailLinkByTeamAndRequest

func NewInviteEmailLinkByTeamAndRequest(team *Team, req *InviteMemberByEmailRequest) *Invite

func NewInviteLinkByTeamAndUserRole

func NewInviteLinkByTeamAndUserRole(team *Team, userRole int) *Invite

func (*Invite) ConstructByJSON

func (u *Invite) ConstructByJSON(InviteJSON []byte) error

func (*Invite) Export

func (u *Invite) Export() *InviteForExport

func (*Invite) ExportAppIDInString

func (u *Invite) ExportAppIDInString() string

func (*Invite) ExportEmail

func (u *Invite) ExportEmail() string

func (*Invite) ExportEmailStatus

func (u *Invite) ExportEmailStatus() bool

func (*Invite) ExportID

func (u *Invite) ExportID() int
func (u *Invite) ExportInviteLink() string

func (*Invite) ExportInviteLinkWithEmailAndTeam

func (u *Invite) ExportInviteLinkWithEmailAndTeam(team *Team) string
func (u *Invite) ExportShareAppLink() string

func (*Invite) ExportShareAppLinkWithEmailANDTeamIdentifier

func (u *Invite) ExportShareAppLinkWithEmailANDTeamIdentifier(team *Team) string

func (*Invite) ExportTeamID

func (u *Invite) ExportTeamID() int

func (*Invite) ExportTeamMemberID

func (u *Invite) ExportTeamMemberID() int

func (*Invite) ExportUID

func (u *Invite) ExportUID() uuid.UUID

func (*Invite) ExportUserRole

func (u *Invite) ExportUserRole() int
func (u *Invite) ImportInviteLink(link string) error

func (*Invite) InitCreatedAt

func (u *Invite) InitCreatedAt()

func (*Invite) InitUID

func (u *Invite) InitUID()

func (*Invite) InitUpdatedAt

func (u *Invite) InitUpdatedAt()

func (*Invite) IsAvaliable

func (u *Invite) IsAvaliable() bool
func (u *Invite) IsEmailInviteLink() bool
func (u *Invite) IsInviteLink() bool

func (*Invite) IsShareAppInvite

func (u *Invite) IsShareAppInvite() bool

func (*Invite) SetAppID

func (u *Invite) SetAppID(appID int)

func (*Invite) SetEmailStatusFailed

func (u *Invite) SetEmailStatusFailed()

func (*Invite) SetEmailStatusSuccess

func (u *Invite) SetEmailStatusSuccess()

func (*Invite) SetHosts

func (u *Invite) SetHosts(hosts string)

func (*Invite) SetTeamIdentifier

func (u *Invite) SetTeamIdentifier(teamIdentifier string)

func (*Invite) SetTeamMemberID

func (u *Invite) SetTeamMemberID(teamMemberID int)

func (*Invite) SetUserRole

func (u *Invite) SetUserRole(role int)

type InviteForExport

type InviteForExport struct {
	ID             int       `json:"id"`
	UID            uuid.UUID `json:"uid"`
	Category       int       `json:"category"`
	TeamID         int       `json:"teamID"`
	TeamMemberID   int       `json:"teamMemberID"`
	TeamIdentifier string    `json:"teamIdentifier"`
	AppID          int       `json:"appID"`
	Email          string    `json:"email"`
	EmailStatus    bool      `json:"emailStatus"`
	UserRole       int       `json:"userRole"`
	Status         int       `json:"status"`
	CreatedAt      time.Time `json:"createdAt"`
	UpdatedAt      time.Time `json:"updatedAt"`
}

type InviteMemberByEmailRequest

type InviteMemberByEmailRequest struct {
	UserRole int    `json:"userRole" validate:"required"`
	Email    string `json:"email" validate:"required,email"`
	AppIDRaw string `json:"appID"` // optional
	Hosts    string `json:"hosts"` // optional
	AppID    int    `json:"-"`     // optional
}

func NewInviteMemberByEmailRequest

func NewInviteMemberByEmailRequest() *InviteMemberByEmailRequest

func (*InviteMemberByEmailRequest) ExportAppID

func (u *InviteMemberByEmailRequest) ExportAppID() int

func (*InviteMemberByEmailRequest) ExportEmail

func (u *InviteMemberByEmailRequest) ExportEmail() string

func (*InviteMemberByEmailRequest) ExportHosts

func (u *InviteMemberByEmailRequest) ExportHosts() string

func (*InviteMemberByEmailRequest) ExportUserRole

func (u *InviteMemberByEmailRequest) ExportUserRole() int

func (*InviteMemberByEmailRequest) Init

func (u *InviteMemberByEmailRequest) Init()

func (*InviteMemberByEmailRequest) IsShareAppInvite

func (u *InviteMemberByEmailRequest) IsShareAppInvite() bool

type InviteMemberByEmailResponse

type InviteMemberByEmailResponse struct {
	Email        string `json:"email"`
	EmailStatus  bool   `json:"emailStatus"`
	UserRole     int    `json:"userRole"`
	TeamMemberID string `json:"teamMemberID"`
	AppID        string `json:"appID"`
	Feedback     string `json:"feedback"`
}

func NewInviteMemberByEmailResponse

func NewInviteMemberByEmailResponse() *InviteMemberByEmailResponse

func NewInviteMemberByEmailResponseByInviteRecord

func NewInviteMemberByEmailResponseByInviteRecord(i *Invite, feedback string) *InviteMemberByEmailResponse

func (*InviteMemberByEmailResponse) ExportForFeedback

func (resp *InviteMemberByEmailResponse) ExportForFeedback() interface{}

func (*InviteMemberByEmailResponse) SetEmail

func (u *InviteMemberByEmailResponse) SetEmail(email string)

func (*InviteMemberByEmailResponse) SetEmailStatus

func (u *InviteMemberByEmailResponse) SetEmailStatus(emailStatus bool)

func (*InviteMemberByEmailResponse) SetEmailStatusByInvite

func (u *InviteMemberByEmailResponse) SetEmailStatusByInvite(i *Invite)

func (*InviteMemberByEmailResponse) SetFeedback

func (u *InviteMemberByEmailResponse) SetFeedback(f string)

func (*InviteMemberByEmailResponse) SetUserRole

func (u *InviteMemberByEmailResponse) SetUserRole(userRole int)

type InviteStorage

type InviteStorage struct {
	// contains filtered or unexported fields
}

func NewInviteStorage

func NewInviteStorage(db *gorm.DB, logger *zap.SugaredLogger) *InviteStorage

func (*InviteStorage) Create

func (d *InviteStorage) Create(u *Invite) (int, error)

func (*InviteStorage) DeleteByID

func (d *InviteStorage) DeleteByID(id int) error

func (*InviteStorage) DeleteByTeamID

func (d *InviteStorage) DeleteByTeamID(teamID int) error

func (*InviteStorage) DeleteByTeamIDAndTeamMemberID

func (d *InviteStorage) DeleteByTeamIDAndTeamMemberID(teamID int, teamMemberID int) error

func (*InviteStorage) DeleteByUID

func (d *InviteStorage) DeleteByUID(uid uuid.UUID) error

func (*InviteStorage) RetrieveAvaliableInviteByTeamIDAndEmail

func (d *InviteStorage) RetrieveAvaliableInviteByTeamIDAndEmail(teamID int, email string) (*Invite, error)

func (*InviteStorage) RetrieveAvaliableInviteByTeamIDAndTeamMemberID

func (d *InviteStorage) RetrieveAvaliableInviteByTeamIDAndTeamMemberID(teamID int, teamMemberID int) (*Invite, error)

func (*InviteStorage) RetrieveAvaliableInviteLinkByTeamIDAndUserRole

func (d *InviteStorage) RetrieveAvaliableInviteLinkByTeamIDAndUserRole(teamID int, userRole int) (*Invite, error)

func (*InviteStorage) RetrieveByID

func (d *InviteStorage) RetrieveByID(id int) (*Invite, error)

func (*InviteStorage) RetrieveByIDs

func (d *InviteStorage) RetrieveByIDs(ids []int) ([]*Invite, error)

func (*InviteStorage) RetrieveByUID

func (d *InviteStorage) RetrieveByUID(uid uuid.UUID) (*Invite, error)

func (*InviteStorage) RetrieveInviteByEmailAndTeamIDAndUserRole

func (d *InviteStorage) RetrieveInviteByEmailAndTeamIDAndUserRole(teamID int, email string, userRole int) (*Invite, error)

Note: this method is not avaliable invite record inluded.

func (*InviteStorage) RetrieveInviteByEmailByIDs

func (d *InviteStorage) RetrieveInviteByEmailByIDs(ids []int) ([]*Invite, error)

func (*InviteStorage) RetrieveInviteByTeamIDAndEmail

func (d *InviteStorage) RetrieveInviteByTeamIDAndEmail(teamID int, email string) (*Invite, error)

func (*InviteStorage) Update

func (d *InviteStorage) Update(u *Invite) error

type MyTeam

type MyTeam struct {
	ID                   string                `json:"id"`
	UID                  uuid.UUID             `json:"uid"`
	Name                 string                `json:"name"`
	Identifier           string                `json:"identifier"`
	Icon                 string                `json:"icon"`
	MyRole               int                   `json:"myRole"`
	TeamMemberID         string                `json:"teamMemberID"`
	TeamMemberPermission *TeamMemberPermission `json:"teamMemberPermission"`
	TeamPermission       *TeamPermission       `json:"permission"`
	JoinedAt             time.Time             `json:"-"`
}

type Response

type Response interface {
	ExportForFeedback() interface{}
}

type S3Instance

type S3Instance interface {
	GetPreSignedPutURL(fileName string) (string, error)
}

type SignInRequest

type SignInRequest struct {
	Email    string `json:"email" validate:"required"`
	Password string `json:"password" validate:"required"`
}

func NewSignInRequest

func NewSignInRequest() *SignInRequest

type SignUpRequest

type SignUpRequest struct {
	Nickname          string `json:"nickname" validate:"required"`
	Email             string `json:"email" validate:"required"`
	Password          string `json:"password" validate:"required"`
	Language          string `json:"language" validate:"oneof=zh-CN en-US ja-JP ko-KR"`
	IsSubscribed      bool   `json:"isSubscribed"`      // is subscribed are optional
	VerificationCode  string `json:"verificationCode"`  // @todo: add validate:"required" when uset smtp server configureable
	VerificationToken string `json:"verificationToken"` // @todo: add validate:"required" when uset smtp server configureable
	InviteToken       string `json:"inviteToken"`       // invite token are optional
}

func NewSignUpRequest

func NewSignUpRequest() *SignUpRequest

func (*SignUpRequest) ExportEmail

func (u *SignUpRequest) ExportEmail() string

func (*SignUpRequest) ExportInviteToken

func (u *SignUpRequest) ExportInviteToken() string
func (u *SignUpRequest) IsSignUpWithInviteLink() bool

type SignUpResponse

type SignUpResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewSignUpResponse

func NewSignUpResponse(u *User) *SignUpResponse

func (*SignUpResponse) ExportForFeedback

func (resp *SignUpResponse) ExportForFeedback() interface{}

type Storage

type Storage struct {
	UserStorage       *UserStorage
	TeamStorage       *TeamStorage
	TeamMemberStorage *TeamMemberStorage
	InviteStorage     *InviteStorage
}

func NewStorage

func NewStorage(postgresDriver *gorm.DB, logger *zap.SugaredLogger) *Storage

type SystemDrive

type SystemDrive struct {
	Drive      S3Instance `json:"-"`
	UserFolder string     `json:"userFolder"`
}

func NewSystemDrive

func NewSystemDrive(drive *Drive) *SystemDrive

func (*SystemDrive) GetUserAvatarUploadPreSignedURL

func (d *SystemDrive) GetUserAvatarUploadPreSignedURL(fileName string) (string, error)

func (*SystemDrive) SetUser

func (d *SystemDrive) SetUser(user *User)

type Team

type Team struct {
	ID         int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:teams_ukey"`
	UID        uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:teams_ukey"`
	Name       string    `json:"name" gorm:"column:name;type:varchar;size:255;not null"`
	Identifier string    `json:"identifier" gorm:"column:identifier;type:varchar;size:255;not null"`
	Icon       string    `json:"icon" gorm:"column:icon;type:varchar;size:255;not null"`
	Permission string    `json:"permission" gorm:"column:permission;type:jsonb"` // for team permission config
	CreatedAt  time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewTeam

func NewTeam() *Team

func (*Team) ConfigInviteLinkByRequest

func (u *Team) ConfigInviteLinkByRequest(req *ConfigInviteLinkRequest)

func (*Team) ConstructByJSON

func (u *Team) ConstructByJSON(TeamJSON []byte) error

func (*Team) DoesEditorOrViewerCanInviteMember

func (u *Team) DoesEditorOrViewerCanInviteMember() bool

func (*Team) Export

func (t *Team) Export() *TeamForExport

func (*Team) ExportID

func (u *Team) ExportID() int

func (*Team) ExportTeamPermission

func (u *Team) ExportTeamPermission() *TeamPermission

func (*Team) GetIdentifier

func (u *Team) GetIdentifier() string

func (*Team) GetUID

func (u *Team) GetUID() uuid.UUID

func (*Team) GetUIDInString

func (u *Team) GetUIDInString() string

func (*Team) InitCreatedAt

func (u *Team) InitCreatedAt()

func (*Team) InitUID

func (u *Team) InitUID()

func (*Team) InitUpdatedAt

func (u *Team) InitUpdatedAt()

func (*Team) SetTeamPermission

func (u *Team) SetTeamPermission(tp *TeamPermission)

func (*Team) UpdateByUpdateTeamConfigRawRequest

func (u *Team) UpdateByUpdateTeamConfigRawRequest(rawReq map[string]interface{}) error

func (*Team) UpdateByUpdateTeamPermissionRawRequest

func (u *Team) UpdateByUpdateTeamPermissionRawRequest(rawReq map[string]interface{}) error

type TeamDrive

type TeamDrive struct {
	UID              uuid.UUID  `json:"uid"`
	Drive            S3Instance `json:"-"`
	TeamSystemFolder string     `json:"teamsystemfolder"`
	TeamSpaceFolder  string     `json:"teamspacefolder"`
}

func NewTeamDrive

func NewTeamDrive(drive *Drive) *TeamDrive

func (*TeamDrive) GetIconUploadPreSignedURL

func (d *TeamDrive) GetIconUploadPreSignedURL(fileName string) (string, error)

func (*TeamDrive) SetTeam

func (d *TeamDrive) SetTeam(team *Team)

type TeamForExport

type TeamForExport struct {
	ID         int             `json:"id"`
	UID        uuid.UUID       `json:"uid"`
	Name       string          `json:"name"`
	Identifier string          `json:"identifier"`
	Icon       string          `json:"icon"`
	Permission *TeamPermission `json:"permission"`
	CreatedAt  time.Time       `json:"createdAt"`
	UpdatedAt  time.Time       `json:"updatedAt"`
}

type TeamIconUploadAddressResponse

type TeamIconUploadAddressResponse struct {
	UploadAddress string `json:"uploadAddress"`
}

func NewTeamIconUploadAddressResponse

func NewTeamIconUploadAddressResponse(presignedURL string) *TeamIconUploadAddressResponse

func (*TeamIconUploadAddressResponse) ExportForFeedback

func (resp *TeamIconUploadAddressResponse) ExportForFeedback() interface{}

type TeamMember

type TeamMember struct {
	ID         int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:team_members_ukey"`
	TeamID     int       `json:"team_id" gorm:"column:team_id;type:bigserial;index:team_members_team_and_user_id"`
	UserID     int       `json:"user_id" gorm:"column:user_id;type:bigserial;index:team_members_team_and_user_id"`
	UserRole   int       `json:"user_role" gorm:"column:user_role;type:smallint"`
	Permission string    `json:"permission" gorm:"column:permission;type:jsonb"` // for user permission config
	Status     int       `json:"status" gorm:"column:status;type:smallint"`
	CreatedAt  time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewEditorTeamMemberByUserID

func NewEditorTeamMemberByUserID(userID int) *TeamMember

func NewPendingTeamMemberByInvite

func NewPendingTeamMemberByInvite(invite *Invite) *TeamMember

func NewTeamMember

func NewTeamMember() *TeamMember

func NewTeamMemberByCreateTeamMemberRequest

func NewTeamMemberByCreateTeamMemberRequest(req *CreateTeamMemberRequest) *TeamMember

func NewTeamMemberByInviteAndUserID

func NewTeamMemberByInviteAndUserID(invite *Invite, userID int) *TeamMember

func NewTeamMemberByTeamIDAndUserIDAndUserRole

func NewTeamMemberByTeamIDAndUserIDAndUserRole(teamID, userID, userRole int) *TeamMember

func NewTeamMemberByUpdateTeamMemberRequest

func NewTeamMemberByUpdateTeamMemberRequest(req *UpdateTeamMemberRequest) *TeamMember

func (*TeamMember) ActiveUser

func (u *TeamMember) ActiveUser()

func (*TeamMember) ConstructByJSON

func (u *TeamMember) ConstructByJSON(TeamMemberJSON []byte) error

func (*TeamMember) Export

func (u *TeamMember) Export() *TeamMemberForExport

func (*TeamMember) ExportID

func (u *TeamMember) ExportID() int

func (*TeamMember) ExportPermission

func (u *TeamMember) ExportPermission() *TeamMemberPermission

func (*TeamMember) ExportUserID

func (u *TeamMember) ExportUserID() int

func (*TeamMember) ExportUserRole

func (u *TeamMember) ExportUserRole() int

func (*TeamMember) ExportWithPendingUserInfo

func (u *TeamMember) ExportWithPendingUserInfo(userForExport *UserForExport) *TeamMemberWithUserInfoForExport

func (*TeamMember) ExportWithUserInfo

func (u *TeamMember) ExportWithUserInfo(userForExport *UserForExport) *TeamMemberWithUserInfoForExport

func (*TeamMember) InitCreatedAt

func (u *TeamMember) InitCreatedAt()

func (*TeamMember) InitUpdatedAt

func (u *TeamMember) InitUpdatedAt()

func (*TeamMember) IsAdmin

func (u *TeamMember) IsAdmin() bool

func (*TeamMember) IsEditor

func (u *TeamMember) IsEditor() bool

func (*TeamMember) IsOwner

func (u *TeamMember) IsOwner() bool

func (*TeamMember) IsStatusOK

func (u *TeamMember) IsStatusOK() bool

func (*TeamMember) IsStatusPending

func (u *TeamMember) IsStatusPending() bool

func (*TeamMember) IsViewer

func (u *TeamMember) IsViewer() bool

func (*TeamMember) SetID

func (u *TeamMember) SetID(id int)

func (*TeamMember) SetUserID

func (u *TeamMember) SetUserID(userID int)

func (*TeamMember) SetUserRole

func (u *TeamMember) SetUserRole(userRole int)

func (*TeamMember) UpdateByUpdateTeamMemberRoleRequest

func (u *TeamMember) UpdateByUpdateTeamMemberRoleRequest(req *UpdateTeamMemberRoleRequest)

func (*TeamMember) UpdateTeamMemberRole

func (u *TeamMember) UpdateTeamMemberRole(userRole int)

type TeamMemberForExport

type TeamMemberForExport struct {
	ID         int                   `json:"id"`
	TeamID     int                   `json:"teamID"`
	UserID     int                   `json:"userID"`
	UserRole   int                   `json:"userRole"`
	Permission *TeamMemberPermission `json:"permission"` // for user permission config
	Status     int                   `json:"status"`
	CreatedAt  time.Time             `json:"createdAt"`
	UpdatedAt  time.Time             `json:"updatedAt"`
}

type TeamMemberPermission

type TeamMemberPermission struct {
	Config int `json:"config"`
}

func NewTeamMemberPermission

func NewTeamMemberPermission() *TeamMemberPermission

func (*TeamMemberPermission) ExportForTeam

func (tmp *TeamMemberPermission) ExportForTeam() string

type TeamMemberStorage

type TeamMemberStorage struct {
	// contains filtered or unexported fields
}

func NewTeamMemberStorage

func NewTeamMemberStorage(db *gorm.DB, logger *zap.SugaredLogger) *TeamMemberStorage

func (*TeamMemberStorage) Create

func (d *TeamMemberStorage) Create(u *TeamMember) (int, error)

func (*TeamMemberStorage) DeleteByID

func (d *TeamMemberStorage) DeleteByID(id int) error

func (*TeamMemberStorage) DeleteByIDAndTeamID

func (d *TeamMemberStorage) DeleteByIDAndTeamID(id int, teamID int) error

func (*TeamMemberStorage) DeleteByTeamID

func (d *TeamMemberStorage) DeleteByTeamID(teamID int) error

func (*TeamMemberStorage) DeleteByTeamIDAndUserID

func (d *TeamMemberStorage) DeleteByTeamIDAndUserID(teamID int, userID int) error

func (*TeamMemberStorage) DeleteByUID

func (d *TeamMemberStorage) DeleteByUID(uid string) error

func (*TeamMemberStorage) DeleteByUserID

func (d *TeamMemberStorage) DeleteByUserID(userID int) error

func (*TeamMemberStorage) DoesTeamIncludedTargetUser

func (d *TeamMemberStorage) DoesTeamIncludedTargetUser(teamID int, userID int) (bool, error)

func (*TeamMemberStorage) IsNowUserIsTeamOwner

func (d *TeamMemberStorage) IsNowUserIsTeamOwner(userID int) (bool, error)

func (*TeamMemberStorage) RetrieveByID

func (d *TeamMemberStorage) RetrieveByID(id int) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByTeamID

func (d *TeamMemberStorage) RetrieveByTeamID(team_id int) ([]*TeamMember, error)

func (*TeamMemberStorage) RetrieveByTeamIDAndID

func (d *TeamMemberStorage) RetrieveByTeamIDAndID(team_id int, id int) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByTeamIDAndUserID

func (d *TeamMemberStorage) RetrieveByTeamIDAndUserID(teamID int, userID int) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByUID

func (d *TeamMemberStorage) RetrieveByUID(uid string) (*TeamMember, error)

func (*TeamMemberStorage) RetrieveByUserID

func (d *TeamMemberStorage) RetrieveByUserID(user_id int) ([]*TeamMember, error)

func (*TeamMemberStorage) RetrieveTeamMemberByTeamIDAndID

func (d *TeamMemberStorage) RetrieveTeamMemberByTeamIDAndID(teamID int, id int) (*TeamMember, error)

func (*TeamMemberStorage) Update

func (d *TeamMemberStorage) Update(u *TeamMember) error

type TeamMemberWithUserInfoForExport

type TeamMemberWithUserInfoForExport struct {
	ID           int                   `json:"userID"`
	UID          uuid.UUID             `json:"uid"`
	TeamMemberID int                   `json:"teamMemberID"`
	Nickname     string                `json:"nickname"`
	Email        string                `json:"email"`
	Avatar       string                `json:"avatar"`
	Language     string                `json:"language"`
	IsSubscribed bool                  `json:"isSubscribed"`
	UserRole     int                   `json:"userRole"`
	Permission   *TeamMemberPermission `json:"permission"` // for user permission config
	UserStatus   int                   `json:"userStatus"`
	CreatedAt    time.Time             `json:"createdAt"`
	UpdatedAt    time.Time             `json:"updatedAt"`
}

type TeamMemberWithUserInfoForExportConverted

type TeamMemberWithUserInfoForExportConverted struct {
	ID           string                `json:"userID"`
	UID          uuid.UUID             `json:"uid"`
	TeamMemberID string                `json:"teamMemberID"`
	Nickname     string                `json:"nickname"`
	Email        string                `json:"email"`
	Avatar       string                `json:"avatar"`
	Language     string                `json:"language"`
	IsSubscribed bool                  `json:"isSubscribed"`
	UserRole     int                   `json:"userRole"`
	Permission   *TeamMemberPermission `json:"permission"` // for user permission config
	UserStatus   int                   `json:"userStatus"`
	CreatedAt    time.Time             `json:"createdAt"`
	UpdatedAt    time.Time             `json:"updatedAt"`
}

type TeamPermission

type TeamPermission struct {
	AllowEditorInvite           bool `json:"allowEditorInvite"`
	AllowViewerInvite           bool `json:"allowViewerInvite"`
	AllowEditorManageTeamMember bool `json:"allowEditorManageTeamMember"`
	AllowViewerManageTeamMember bool `json:"allowViewerManageTeamMember"`
	InviteLinkEnabled           bool `json:"inviteLinkEnabled"`
}

func NewTeamPermission

func NewTeamPermission() *TeamPermission
func (tp *TeamPermission) DisableInviteLink()

func (*TeamPermission) DoesEditorCanManageTeamMember

func (tp *TeamPermission) DoesEditorCanManageTeamMember() bool

func (*TeamPermission) DoesInviteLinkEnabled

func (tp *TeamPermission) DoesInviteLinkEnabled() bool

func (*TeamPermission) DoesViewerCanManageTeamMember

func (tp *TeamPermission) DoesViewerCanManageTeamMember() bool
func (tp *TeamPermission) EnableInviteLink()

func (*TeamPermission) ExportForTeam

func (tp *TeamPermission) ExportForTeam() string

func (*TeamPermission) ImportFromTeam

func (tp *TeamPermission) ImportFromTeam(team *Team)

type TeamStorage

type TeamStorage struct {
	// contains filtered or unexported fields
}

func NewTeamStorage

func NewTeamStorage(db *gorm.DB, logger *zap.SugaredLogger) *TeamStorage

func (*TeamStorage) Create

func (d *TeamStorage) Create(u *Team) (int, error)

func (*TeamStorage) DeleteByID

func (d *TeamStorage) DeleteByID(id int) error

func (*TeamStorage) DeleteByUID

func (d *TeamStorage) DeleteByUID(uid string) error

func (*TeamStorage) IsIdentifierExists

func (d *TeamStorage) IsIdentifierExists(identifier string) bool

func (*TeamStorage) RetrieveByID

func (d *TeamStorage) RetrieveByID(id int) (*Team, error)

func (*TeamStorage) RetrieveByIDs

func (d *TeamStorage) RetrieveByIDs(ids []int) ([]*Team, error)

func (*TeamStorage) RetrieveByIdentifier

func (d *TeamStorage) RetrieveByIdentifier(identifier string) (*Team, error)

func (*TeamStorage) RetrieveByUID

func (d *TeamStorage) RetrieveByUID(uid string) (*Team, error)

func (*TeamStorage) UpdateByID

func (d *TeamStorage) UpdateByID(u *Team) error

type TeamsForExport

type TeamsForExport []*TeamForExport

func NewTeamsForExport

func NewTeamsForExport(teams []*Team) (r TeamsForExport)

type UpdateAvatarRequest

type UpdateAvatarRequest struct {
	Avatar string `json:"avatar" validate:"required"`
}

func NewUpdateAvatarRequest

func NewUpdateAvatarRequest() *UpdateAvatarRequest

type UpdateDomainRequest

type UpdateDomainRequest struct {
	ID                 int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:domains_ukey"`
	UID                uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:domains_ukey"`
	TeamID             int       `json:"teamID" gorm:"column:team_id;type:bigserial;index:domains_team_id"`
	UserDomain         string    `json:"userDomain" gorm:"column:user_domain;type:varchar;size:255;not null"`
	SystemDomainPrefix string    `json:"systemDomain_prefix" gorm:"column:system_domain_prefix;type:varchar;size:255;not null"`
	ResolveStatus      int       `json:"resolveStatus" gorm:"column:resolve_status;type:smallint;"`
	Category           int       `json:"category" gorm:"column:category;type:smallint;"`
}

func NewUpdateDomainRequest

func NewUpdateDomainRequest() *UpdateDomainRequest

type UpdateInvitationCodeRequest

type UpdateInvitationCodeRequest struct {
	ID            int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:teams_ukey"`
	UID           uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:teams_ukey"`
	TeamID        int       `json:"teamID" gorm:"column:team_id;type:bigserial;index:invitation_code_team_id"`
	ConsumeStatus int       `json:"consumeStatus" gorm:"column:consume_status;type:smallint;"`
}

func NewUpdateInvitationCodeRequest

func NewUpdateInvitationCodeRequest() *UpdateInvitationCodeRequest

type UpdateInviteRequest

type UpdateInviteRequest struct {
	ID       int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:invite_ukey"`
	UID      uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:invite_uid"`
	TeamID   int       `json:"teamID" gorm:"column:team_id;type:bigserial;index:users_ukey"`
	Email    string    `json:"email" gorm:"column:email;type:varchar;size:255;;index:invite_email"`
	UserRole int       `json:"userRole" gorm:"column:user_role;type:smallint;index:invite_user_role"`
	Status   int       `json:"status" gorm:"column:status;type:smallint;index:users_ukey"`
}

func NewUpdateInviteRequest

func NewUpdateInviteRequest() *UpdateInviteRequest

type UpdateLanguageRequest

type UpdateLanguageRequest struct {
	Language string `json:"language" validate:"oneof=zh-CN en-US ja-JP ko-KR"`
}

func NewUpdateLanguageRequest

func NewUpdateLanguageRequest() *UpdateLanguageRequest

type UpdateNicknameRequest

type UpdateNicknameRequest struct {
	Nickname string `json:"nickname" validate:"required"`
}

func NewUpdateNicknameRequest

func NewUpdateNicknameRequest() *UpdateNicknameRequest

type UpdateTeamConfigRequest

type UpdateTeamConfigRequest struct {
	Name       string `json:"name" validate:"required"`
	Identifier string `json:"identifier" validate:"required"`
	Icon       string `json:"icon"`
}

func NewUpdateTeamConfigRequest

func NewUpdateTeamConfigRequest(rawReq map[string]interface{}) *UpdateTeamConfigRequest

type UpdateTeamMemberRequest

type UpdateTeamMemberRequest struct {
	ID         int    `json:"id" gorm:"column:id;type:bigserial;primary_key;index:team_members_ukey"`
	TeamID     int    `json:"teamID" gorm:"column:team_id;type:bigserial;index:team_members_team_and_user_id"`
	UserID     int    `json:"userID" gorm:"column:user_id;type:bigserial;index:team_members_team_and_user_id"`
	UserRole   int    `json:"userRole" gorm:"column:user_role;type:smallint"`
	Permission string `json:"permission" gorm:"column:authority;type:jsonb"` // for user permission config
}

func NewUpdateTeamMemberRequest

func NewUpdateTeamMemberRequest() *UpdateTeamMemberRequest

type UpdateTeamMemberRoleRequest

type UpdateTeamMemberRoleRequest struct {
	UserRole int `json:"userRole" validate:"required"`
}

func NewUpdateTeamMemberRoleRequest

func NewUpdateTeamMemberRoleRequest() *UpdateTeamMemberRoleRequest

func (*UpdateTeamMemberRoleRequest) ExportUserRole

func (u *UpdateTeamMemberRoleRequest) ExportUserRole() int

func (*UpdateTeamMemberRoleRequest) IsTransferOwner

func (u *UpdateTeamMemberRoleRequest) IsTransferOwner() bool

type UpdateTeamPermissionRequest

type UpdateTeamPermissionRequest struct {
	AllowEditorInvite           bool `json:"allowEditorInvite"`
	AllowViewerInvite           bool `json:"allowViewerInvite"`
	AllowEditorManageTeamMember bool `json:"allowEditorManageTeamMember"`
	AllowViewerManageTeamMember bool `json:"allowViewerManageTeamMember"`
}

func NewUpdateTeamPermissionRequest

func NewUpdateTeamPermissionRequest(rawReq map[string]interface{}) *UpdateTeamPermissionRequest

type UpdateUserRequest

type UpdateUserRequest struct {
	ID             string    `json:"id" gorm:"column:id;type:bigserial;primary_key;index:users_ukey"`
	UID            uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:users_ukey"`
	Nickname       string    `json:"nickname" gorm:"column:nickname;type:varchar;size:15;not null"`
	PasswordDigest string    `json:"passworddigest" gorm:"column:password_digest;type:varchar;size:60;not null"`
	Email          string    `json:"email" gorm:"column:email;type:varchar;size:255;not null"`
	Avatar         string    `json:"avatar" gorm:"column:avatar;type:varchar;size:255;not null"`
	SSOConfig      string    `json:"SSOConfig" gorm:"column:sso_config;type:jsonb"`        // for single sign-on data
	Customization  string    `json:"customization" gorm:"column:customization;type:jsonb"` // for user itself customization config, including: Language, IsSubscribed

}

func NewUpdateUserRequest

func NewUpdateUserRequest() *UpdateUserRequest

type UpdateUserResponse

type UpdateUserResponse struct {
	ID           string    `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID string    `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func NewUpdateUserResponse

func NewUpdateUserResponse(user *User) *UpdateUserResponse

func (*UpdateUserResponse) ExportForFeedback

func (resp *UpdateUserResponse) ExportForFeedback() interface{}

type User

type User struct {
	ID             int       `json:"id" gorm:"column:id;type:bigserial;primary_key;index:users_ukey"`
	UID            uuid.UUID `json:"uid" gorm:"column:uid;type:uuid;not null;index:users_ukey"`
	Nickname       string    `json:"nickname" gorm:"column:nickname;type:varchar;size:15"`
	PasswordDigest string    `json:"passworddigest" gorm:"column:password_digest;type:varchar;size:60;not null"`
	Email          string    `json:"email" gorm:"column:email;type:varchar;size:255;not null"`
	Avatar         string    `json:"avatar" gorm:"column:avatar;type:varchar;size:255;not null"`
	SSOConfig      string    `json:"SSOConfig" gorm:"column:sso_config;type:jsonb"`        // for single sign-on data
	Customization  string    `json:"customization" gorm:"column:customization;type:jsonb"` // for user itself customization config, including: Language, IsSubscribed
	CreatedAt      time.Time `gorm:"column:created_at;type:timestamp"`
	UpdatedAt      time.Time `gorm:"column:updated_at;type:timestamp"`
}

func NewPendingUserByInvite

func NewPendingUserByInvite(i *Invite) (*User, error)

func NewPendingUserByInviteForExport

func NewPendingUserByInviteForExport(inviteForExport *InviteForExport) (*User, error)

func NewUser

func NewUser() *User

func NewUserByCreateUserRequest

func NewUserByCreateUserRequest(req *CreateUserRequest) *User

func NewUserBySignUpRequest

func NewUserBySignUpRequest(req *SignUpRequest) (*User, error)

func (*User) ConstructByJSON

func (u *User) ConstructByJSON(userJSON []byte) error

func (*User) Export

func (u *User) Export() *UserForExport

func (*User) ExportEmail

func (u *User) ExportEmail() string

func (*User) ExportID

func (u *User) ExportID() int

func (*User) ExportLanguage

func (u *User) ExportLanguage() string

func (*User) ExportUserCustomization

func (u *User) ExportUserCustomization() *UserCustomization

func (*User) GetUIDInString

func (u *User) GetUIDInString() string

func (*User) InitCreatedAt

func (u *User) InitCreatedAt()

func (*User) InitUID

func (u *User) InitUID()

func (*User) InitUpdatedAt

func (u *User) InitUpdatedAt()

func (*User) SetAvatar

func (u *User) SetAvatar(avatar string)

func (*User) SetID

func (u *User) SetID(id int)

func (*User) SetLanguage

func (u *User) SetLanguage(language string)

func (*User) SetNickname

func (u *User) SetNickname(nickname string)

func (*User) SetPasswordByByte

func (u *User) SetPasswordByByte(password []byte)

func (*User) SetUserCustomization

func (u *User) SetUserCustomization(userCustomization *UserCustomization)

func (*User) UpdateByUpdateUserAvatarRequest

func (u *User) UpdateByUpdateUserAvatarRequest(req *UpdateAvatarRequest)

func (*User) UpdatePendingUserBySignUpRequest

func (u *User) UpdatePendingUserBySignUpRequest(req *SignUpRequest) error

type UserAvatarUploadAddressResponse

type UserAvatarUploadAddressResponse struct {
	UploadAddress string `json:"uploadAddress"`
}

func NewUserAvatarUploadAddressResponse

func NewUserAvatarUploadAddressResponse(presignedURL string) *UserAvatarUploadAddressResponse

func (*UserAvatarUploadAddressResponse) ExportForFeedback

func (resp *UserAvatarUploadAddressResponse) ExportForFeedback() interface{}

type UserCustomization

type UserCustomization struct {
	Language     string
	IsSubscribed bool
}

func NewUserCustomization

func NewUserCustomization() *UserCustomization

func NewUserCustomizationBySignUpRequest

func NewUserCustomizationBySignUpRequest(req *SignUpRequest) *UserCustomization

func (*UserCustomization) Export

func (c *UserCustomization) Export() (string, error)

func (*UserCustomization) SetIsSubscribed

func (c *UserCustomization) SetIsSubscribed(isSubscribed bool)

func (*UserCustomization) SetLanguage

func (c *UserCustomization) SetLanguage(language string)

type UserForExport

type UserForExport struct {
	ID           int       `json:"id"`
	UID          uuid.UUID `json:"uid"`
	TeamMemberID int       `json:"teamMemberID"`
	Nickname     string    `json:"nickname"`
	Email        string    `json:"email"`
	Avatar       string    `json:"avatar"`
	Language     string    `json:"language"`
	IsSubscribed bool      `json:"isSubscribed"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func (*UserForExport) SetTeamMemberID

func (ufe *UserForExport) SetTeamMemberID(teamMemberID int)

type UserSSOConfig

type UserSSOConfig struct {
	Github string
}

func NewUserSSOConfig

func NewUserSSOConfig() *UserSSOConfig

func (*UserSSOConfig) Export

func (u *UserSSOConfig) Export() string

type UserStorage

type UserStorage struct {
	// contains filtered or unexported fields
}

func NewUserStorage

func NewUserStorage(db *gorm.DB, logger *zap.SugaredLogger) *UserStorage

func (*UserStorage) Create

func (d *UserStorage) Create(u *User) (int, error)

func (*UserStorage) DeleteByID

func (d *UserStorage) DeleteByID(id int) error

func (*UserStorage) DeleteByUID

func (d *UserStorage) DeleteByUID(uid string) error

func (*UserStorage) RetrieveByEmail

func (d *UserStorage) RetrieveByEmail(email string) (*User, error)

func (*UserStorage) RetrieveByID

func (d *UserStorage) RetrieveByID(id int) (*User, error)

func (*UserStorage) RetrieveByIDAndUID

func (d *UserStorage) RetrieveByIDAndUID(id int, uid uuid.UUID) (*User, error)

func (*UserStorage) RetrieveByIDs

func (d *UserStorage) RetrieveByIDs(ids []int) ([]*User, error)

func (*UserStorage) RetrieveByUID

func (d *UserStorage) RetrieveByUID(uid uuid.UUID) (*User, error)

func (*UserStorage) UpdateByID

func (d *UserStorage) UpdateByID(u *User) error

func (*UserStorage) ValidateUser

func (d *UserStorage) ValidateUser(id int, uid uuid.UUID) (bool, error)

type VCodeClaims

type VCodeClaims struct {
	Email string `json:"email"`
	Code  string `json:"code"`
	Usage string `json:"usage"`
	jwt.RegisteredClaims
}

type VerificationRequest

type VerificationRequest struct {
	Email string `json:"email" validate:"required"`
	Usage string `json:"usage" validate:"oneof=signup forgetpwd"`
}

func NewVerificationRequest

func NewVerificationRequest() *VerificationRequest

Jump to

Keyboard shortcuts

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