repo

package
v0.0.0-...-4df811a Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 17 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package repo provides ...

Index

Constants

View Source
const (
	DialectPostgres = iota
	DialectSQLite
)

Variables

View Source
var (
	ErrorNotFound  = errors.New("not found")
	ErrorBadName   = errors.New("bad name")
	ErrorNameTaken = errors.New("name taken")
)

Functions

func AutoMigrate

func AutoMigrate() error

func Transaction

func Transaction(fn func(IRepo) error) error

Types

type Dialect

type Dialect int

type IRepo

type IRepo interface {
	CreateEnvironment(*models.Environment) IRepo
	CreateEnvironmentType(*models.EnvironmentType) IRepo
	CreateLoginRequest() models.LoginRequest
	CreateProjectMember(*models.ProjectMember, *models.Role) IRepo
	CreateRole(*models.Role) IRepo
	CreateRoleEnvironmentType(*models.RolesEnvironmentType) IRepo
	DeleteLoginRequest(string) bool
	DeleteAllProjectMembers(project *models.Project) IRepo
	DeleteExpiredMessages() IRepo
	GetGroupedMessagesWillExpireByUser(groupedMessageUser *map[uint]emailer.GroupedMessagesUser) IRepo
	DeleteMessage(messageID uint, userID uint) IRepo
	DeleteProject(project *models.Project) IRepo
	DeleteProjectsEnvironments(project *models.Project) IRepo
	Err() error
	ClearErr() IRepo
	FindUsers(userIDs []string, users *map[string]models.User, notFounds *[]string) IRepo
	GetActivityLogs(projectID string, options models.GetLogsOptions, logs *[]models.ActivityLog) IRepo
	GetChildrenRoles(role models.Role, roles *[]models.Role) IRepo
	GetDb() *gorm.DB
	GetEnvironment(*models.Environment) IRepo
	GetEnvironmentPublicKeys(envID string, publicKeys *models.PublicKeys) IRepo
	GetEnvironmentType(*models.EnvironmentType) IRepo
	GetEnvironmentsByProjectUUID(projectUUID string, foundEnvironments *[]models.Environment) IRepo
	GetInvitableRoles(models.Role, *[]models.Role) IRepo
	GetLoginRequest(string) (models.LoginRequest, bool)
	GetMessage(message *models.Message) IRepo
	GetMessagesForUserOnEnvironment(device models.Device, environment models.Environment, message *models.Message) IRepo
	GetOrCreateEnvironment(*models.Environment) IRepo
	GetOrCreateEnvironmentType(*models.EnvironmentType) IRepo
	GetOrCreateProject(*models.Project) IRepo
	GetOrCreateProjectMember(*models.ProjectMember, string) IRepo
	GetOrCreateRole(*models.Role) IRepo
	GetOrCreateRoleEnvType(*models.RolesEnvironmentType) IRepo
	GetOrCreateUser(*models.User) IRepo
	GetProject(*models.Project) IRepo
	GetProjectByUUID(string, *models.Project) IRepo
	GetProjectMember(*models.ProjectMember) IRepo
	GetProjectsOrganization(string, *models.Organization) IRepo
	OrganizationCountMembers(*models.Organization, *int64) IRepo
	GetRole(*models.Role) IRepo
	GetRoles(*[]models.Role) IRepo
	GetRolesEnvironmentType(environmentType *models.RolesEnvironmentType) IRepo
	GetRolesMemberCanInvite(projectMember models.ProjectMember, roles *[]models.Role) IRepo
	GetUser(*models.User) IRepo
	GetUserByEmail(string, *[]models.User) IRepo
	IsMemberOfProject(*models.Project, *models.ProjectMember) IRepo
	ListProjectMembers(userIDList []string, projectMember *[]models.ProjectMember) IRepo
	MessageService() message.MessageService
	ProjectAddMembers(models.Project, []models.MemberRole, models.User) IRepo
	UsersInMemberRoles(mers []models.MemberRole) (map[string]models.User, []string)
	SetNewlyCreatedDevice(flag bool, deviceID uint, userID uint) IRepo
	ProjectGetAdmins(project *models.Project, members *[]models.ProjectMember) IRepo
	ProjectIsMemberAdmin(project *models.Project, member *models.ProjectMember) bool
	ProjectGetMembers(*models.Project, *[]models.ProjectMember) IRepo
	ProjectLoadUsers(*models.Project) IRepo
	ProjectRemoveMembers(models.Project, []string) IRepo
	ProjectSetRoleForUser(models.Project, models.User, models.Role) IRepo
	CheckMembersAreInProject(models.Project, []string) ([]string, error)
	RemoveOldMessageForRecipient(userID uint, environmentID string) IRepo
	SaveActivityLog(al *models.ActivityLog) IRepo
	SetLoginRequestCode(string, string) models.LoginRequest
	SetNewVersionID(environment *models.Environment) error
	WriteMessage(user models.User, message models.Message) IRepo
	GetDevices(uint, *[]models.Device) IRepo
	GetNewlyCreatedDevices(*[]models.Device) IRepo
	GetDevice(device *models.Device) IRepo
	GetDeviceByUserID(userID uint, device *models.Device) IRepo
	UpdateDeviceLastUsedAt(deviceUID string) IRepo
	RevokeDevice(userID uint, deviceUID string) IRepo
	GetAdminsFromUserProjects(userID uint, adminProjectsMap *map[string][]string) IRepo
	CreateOrganization(orga *models.Organization) IRepo
	UpdateOrganization(orga *models.Organization) IRepo
	OrganizationSetCustomer(organization *models.Organization, customer string) IRepo
	OrganizationSetSubscription(organization *models.Organization, subscription string) IRepo
	GetOrganization(orga *models.Organization) IRepo
	GetOrganizations(userID uint, result *[]models.Organization) IRepo
	GetOwnedOrganizations(userID uint, result *[]models.Organization) IRepo
	GetOwnedOrganizationByName(userID uint, name string, orgas *[]models.Organization) IRepo
	GetOrganizationByName(userID uint, name string, orga *[]models.Organization) IRepo
	GetOrganizationProjects(*models.Organization, *[]models.Project) IRepo
	GetOrganizationMembers(orgaID uint, result *[]models.ProjectMember) IRepo
	IsUserOwnerOfOrga(*models.User, *models.Organization) (bool, error)
	IsProjectOrganizationPaid(string) (bool, error)
	CreateCheckoutSession(*models.CheckoutSession) IRepo
	GetCheckoutSession(string, *models.CheckoutSession) IRepo
	UpdateCheckoutSession(*models.CheckoutSession) IRepo
	DeleteCheckoutSession(*models.CheckoutSession) IRepo
	OrganizationSetPaid(organization *models.Organization, paid bool) IRepo
	GetUserProjects(userID uint, projects *[]models.Project) IRepo
}

IRepo The Repo interface

type MessagesPayload

type MessagesPayload struct {
	Messages []models.Message `json:"messages"`
}

func (*MessagesPayload) Deserialize

func (gr *MessagesPayload) Deserialize(in io.Reader) error

func (*MessagesPayload) Serialize

func (gr *MessagesPayload) Serialize(out *string) error

type Repo

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

func NewRepo

func NewRepo() *Repo

func (*Repo) AddNewDevice

func (r *Repo) AddNewDevice(
	device models.Device,
	user models.User,
) IRepo

func (*Repo) CheckMembersAreInProject

func (r *Repo) CheckMembersAreInProject(
	project models.Project,
	members []string,
) (areInProjects []string, err error)

func (*Repo) ClearErr

func (repo *Repo) ClearErr() IRepo

func (*Repo) CreateCheckoutSession

func (r *Repo) CreateCheckoutSession(cs *models.CheckoutSession) IRepo

func (*Repo) CreateEnvironment

func (repo *Repo) CreateEnvironment(environment *models.Environment) IRepo

func (*Repo) CreateEnvironmentType

func (repo *Repo) CreateEnvironmentType(envType *models.EnvironmentType) IRepo

func (*Repo) CreateLoginRequest

func (repo *Repo) CreateLoginRequest() models.LoginRequest

func (*Repo) CreateOrganization

func (r *Repo) CreateOrganization(orga *models.Organization) IRepo

func (*Repo) CreateProjectMember

func (repo *Repo) CreateProjectMember(
	projectMember *models.ProjectMember,
	role *models.Role,
) IRepo

func (*Repo) CreateRole

func (repo *Repo) CreateRole(role *models.Role) IRepo

func (*Repo) CreateRoleEnvironmentType

func (repo *Repo) CreateRoleEnvironmentType(
	rolesEnvironmentType *models.RolesEnvironmentType,
) IRepo

func (*Repo) DeleteAllProjectMembers

func (repo *Repo) DeleteAllProjectMembers(project *models.Project) IRepo

func (*Repo) DeleteCheckoutSession

func (r *Repo) DeleteCheckoutSession(cs *models.CheckoutSession) IRepo

func (*Repo) DeleteExpiredMessages

func (repo *Repo) DeleteExpiredMessages() IRepo

Deletes all messages older than a week TODO: avoid SQL dialect spicific features

func (*Repo) DeleteLoginRequest

func (repo *Repo) DeleteLoginRequest(code string) bool

func (*Repo) DeleteMessage

func (repo *Repo) DeleteMessage(messageID uint, userID uint) IRepo

func (*Repo) DeleteProject

func (r *Repo) DeleteProject(project *models.Project) IRepo

func (*Repo) DeleteProjectsEnvironments

func (repo *Repo) DeleteProjectsEnvironments(project *models.Project) IRepo

func (*Repo) Err

func (repo *Repo) Err() error

func (*Repo) FindUsers

func (r *Repo) FindUsers(
	userIDs []string,
	users *map[string]models.User,
	notFounds *[]string,
) IRepo

From a slice of userIDs (<username>@<service>) fetchs the users. Returns the found users and a list of not found userIDs

func (*Repo) GetActivityLogs

func (r *Repo) GetActivityLogs(
	projectID string,
	options models.GetLogsOptions,
	logs *[]models.ActivityLog,
) IRepo

GetActivityLogs returns a list of all activity logs associated with the given project

func (*Repo) GetAdminsFromUserProjects

func (r *Repo) GetAdminsFromUserProjects(
	userID uint,
	adminProjectsMap *map[string][]string,
) IRepo

func (*Repo) GetCheckoutSession

func (r *Repo) GetCheckoutSession(
	sessionID string,
	cs *models.CheckoutSession,
) IRepo

func (*Repo) GetChildrenRoles

func (r *Repo) GetChildrenRoles(role models.Role, roles *[]models.Role) IRepo

func (*Repo) GetDb

func (repo *Repo) GetDb() *gorm.DB

func (*Repo) GetDevice

func (r *Repo) GetDevice(device *models.Device) IRepo

func (*Repo) GetDeviceByUserID

func (r *Repo) GetDeviceByUserID(userID uint, device *models.Device) IRepo

func (*Repo) GetDevices

func (r *Repo) GetDevices(userID uint, devices *[]models.Device) IRepo

func (*Repo) GetDialect

func (repo *Repo) GetDialect() Dialect

func (*Repo) GetEnvironment

func (repo *Repo) GetEnvironment(environment *models.Environment) IRepo

func (*Repo) GetEnvironmentPublicKeys

func (repo *Repo) GetEnvironmentPublicKeys(
	environmentID string,
	publicKeys *models.PublicKeys,
) IRepo

func (*Repo) GetEnvironmentType

func (repo *Repo) GetEnvironmentType(envType *models.EnvironmentType) IRepo

func (*Repo) GetEnvironmentsByProjectUUID

func (repo *Repo) GetEnvironmentsByProjectUUID(
	projectUUID string,
	foundEnvironments *[]models.Environment,
) IRepo

func (*Repo) GetGroupedMessagesWillExpireByUser

func (repo *Repo) GetGroupedMessagesWillExpireByUser(
	groupedMessageUser *map[uint]emailer.GroupedMessagesUser,
) IRepo

GetGroupedMessagesWillExpireByUser method returns messages that are going to expire soon, group by user database id TODO: avoid using dialect specific features

func (*Repo) GetInvitableRoles

func (r *Repo) GetInvitableRoles(role models.Role, roles *[]models.Role) IRepo

func (*Repo) GetLoginRequest

func (repo *Repo) GetLoginRequest(code string) (models.LoginRequest, bool)

func (*Repo) GetMessage

func (repo *Repo) GetMessage(message *models.Message) IRepo

func (*Repo) GetMessagesForUserOnEnvironment

func (repo *Repo) GetMessagesForUserOnEnvironment(
	device models.Device,
	environment models.Environment,
	message *models.Message,
) IRepo

func (*Repo) GetNewlyCreatedDevices

func (r *Repo) GetNewlyCreatedDevices(devices *[]models.Device) IRepo

func (*Repo) GetOrCreateEnvironment

func (repo *Repo) GetOrCreateEnvironment(
	environment *models.Environment,
) IRepo

func (*Repo) GetOrCreateEnvironmentType

func (repo *Repo) GetOrCreateEnvironmentType(envType *models.EnvironmentType) IRepo

func (*Repo) GetOrCreateProject

func (r *Repo) GetOrCreateProject(project *models.Project) IRepo

func (*Repo) GetOrCreateProjectMember

func (repo *Repo) GetOrCreateProjectMember(
	projectMember *models.ProjectMember,
	roleName string,
) IRepo

func (*Repo) GetOrCreateRole

func (repo *Repo) GetOrCreateRole(role *models.Role) IRepo

func (*Repo) GetOrCreateRoleEnvType

func (repo *Repo) GetOrCreateRoleEnvType(
	ret *models.RolesEnvironmentType,
) IRepo

func (*Repo) GetOrCreateUser

func (r *Repo) GetOrCreateUser(user *models.User) IRepo

func (*Repo) GetOrganization

func (r *Repo) GetOrganization(orga *models.Organization) IRepo

func (*Repo) GetOrganizationByName

func (r *Repo) GetOrganizationByName(
	userID uint,
	name string,
	orgas *[]models.Organization,
) IRepo

func (*Repo) GetOrganizationMembers

func (r *Repo) GetOrganizationMembers(
	orgaID uint,
	result *[]models.ProjectMember,
) IRepo

func (*Repo) GetOrganizationProjects

func (r *Repo) GetOrganizationProjects(
	orga *models.Organization,
	projects *[]models.Project,
) IRepo

func (*Repo) GetOrganizations

func (r *Repo) GetOrganizations(
	userID uint,
	orgas *[]models.Organization,
) IRepo

func (*Repo) GetOwnedOrganizationByName

func (r *Repo) GetOwnedOrganizationByName(
	userID uint,
	name string,
	orgas *[]models.Organization,
) IRepo

func (*Repo) GetOwnedOrganizations

func (r *Repo) GetOwnedOrganizations(
	userID uint,
	orgas *[]models.Organization,
) IRepo

func (*Repo) GetProject

func (r *Repo) GetProject(project *models.Project) IRepo

func (*Repo) GetProjectByUUID

func (r *Repo) GetProjectByUUID(uuid string, project *models.Project) IRepo

func (*Repo) GetProjectMember

func (repo *Repo) GetProjectMember(projectMember *models.ProjectMember) IRepo

func (*Repo) GetProjectsOrganization

func (r *Repo) GetProjectsOrganization(
	projectID string,
	organization *models.Organization,
) IRepo

func (*Repo) GetRole

func (repo *Repo) GetRole(role *models.Role) IRepo

func (*Repo) GetRoles

func (r *Repo) GetRoles(roles *[]models.Role) IRepo

func (*Repo) GetRolesEnvironmentType

func (repo *Repo) GetRolesEnvironmentType(
	rolesEnvironmentType *models.RolesEnvironmentType,
) IRepo

func (*Repo) GetRolesMemberCanInvite

func (r *Repo) GetRolesMemberCanInvite(
	projectMember models.ProjectMember,
	roles *[]models.Role,
) IRepo

func (*Repo) GetUser

func (r *Repo) GetUser(user *models.User) IRepo

func (*Repo) GetUserByEmail

func (r *Repo) GetUserByEmail(email string, users *[]models.User) IRepo

func (*Repo) GetUserProjects

func (r *Repo) GetUserProjects(userID uint, projects *[]models.Project) IRepo

func (*Repo) IsMemberOfProject

func (r *Repo) IsMemberOfProject(
	project *models.Project,
	member *models.ProjectMember,
) IRepo

func (*Repo) IsProjectOrganizationPaid

func (r *Repo) IsProjectOrganizationPaid(projectID string) (bool, error)

func (*Repo) IsUserOwnerOfOrga

func (r *Repo) IsUserOwnerOfOrga(
	user *models.User,
	orga *models.Organization,
) (isOwner bool, err error)

func (*Repo) ListProjectMembers

func (repo *Repo) ListProjectMembers(
	userIDList []string,
	projectMember *[]models.ProjectMember,
) IRepo

func (*Repo) MessageService

func (repo *Repo) MessageService() message.MessageService

func (*Repo) OrganizationCountMembers

func (r *Repo) OrganizationCountMembers(
	organization *models.Organization,
	count *int64,
) IRepo

func (*Repo) OrganizationSetCustomer

func (r *Repo) OrganizationSetCustomer(
	organization *models.Organization,
	customer string,
) IRepo

func (*Repo) OrganizationSetPaid

func (r *Repo) OrganizationSetPaid(
	organization *models.Organization,
	paid bool,
) IRepo

func (*Repo) OrganizationSetSubscription

func (r *Repo) OrganizationSetSubscription(
	organization *models.Organization,
	subscription string,
) IRepo

func (*Repo) ProjectAddMembers

func (r *Repo) ProjectAddMembers(
	project models.Project,
	memberRoles []models.MemberRole,
	currentUser models.User,
) IRepo

func (*Repo) ProjectGetAdmins

func (r *Repo) ProjectGetAdmins(
	project *models.Project,
	members *[]models.ProjectMember,
) IRepo

ProjectGetAdmins returns all admins of a project

func (*Repo) ProjectGetMembers

func (r *Repo) ProjectGetMembers(
	project *models.Project,
	members *[]models.ProjectMember,
) IRepo

ProjectGetMembers returns all members of a project with their role

func (*Repo) ProjectIsMemberAdmin

func (r *Repo) ProjectIsMemberAdmin(
	project *models.Project,
	member *models.ProjectMember,
) bool

func (*Repo) ProjectLoadUsers

func (r *Repo) ProjectLoadUsers(project *models.Project) IRepo

func (*Repo) ProjectRemoveMembers

func (r *Repo) ProjectRemoveMembers(
	project models.Project,
	members []string,
) IRepo

func (*Repo) ProjectSetRoleForUser

func (r *Repo) ProjectSetRoleForUser(
	project models.Project,
	user models.User,
	role models.Role,
) IRepo

func (*Repo) RemoveOldMessageForRecipient

func (repo *Repo) RemoveOldMessageForRecipient(
	publicKeyID uint,
	environmentID string,
) IRepo

func (*Repo) RevokeDevice

func (r *Repo) RevokeDevice(userID uint, deviceUID string) IRepo

func (*Repo) SaveActivityLog

func (r *Repo) SaveActivityLog(al *models.ActivityLog) IRepo

func (*Repo) SetLoginRequestCode

func (repo *Repo) SetLoginRequestCode(
	code string,
	authCode string,
) models.LoginRequest

func (*Repo) SetNewVersionID

func (repo *Repo) SetNewVersionID(environment *models.Environment) error

func (*Repo) SetNewlyCreatedDevice

func (r *Repo) SetNewlyCreatedDevice(flag bool, deviceID uint, userID uint) IRepo

func (*Repo) UpdateCheckoutSession

func (r *Repo) UpdateCheckoutSession(cs *models.CheckoutSession) IRepo

func (*Repo) UpdateDeviceLastUsedAt

func (r *Repo) UpdateDeviceLastUsedAt(deviceUID string) IRepo

func (*Repo) UpdateOrganization

func (r *Repo) UpdateOrganization(orga *models.Organization) IRepo

func (*Repo) UsersInMemberRoles

func (r *Repo) UsersInMemberRoles(
	mers []models.MemberRole,
) (map[string]models.User, []string)

From a list of MemberEnvironmentRole, fetches users from database Returns the found Users and a slice of not found userIDs

func (*Repo) WriteMessage

func (repo *Repo) WriteMessage(user models.User, message models.Message) IRepo

Jump to

Keyboard shortcuts

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