data

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName        = "telegram"
	UnverifiedService = "unverified-svc"
	IdentityService   = "identity"
)
View Source
const (
	S3BucketName     = "accesscontrolsystem"
	S3BucketEndpoint = "https://accesscontrolsystem.s3.eu-north-1.amazonaws.com"
)
View Source
const (
	OrderAscending  = "asc"
	OrderDescending = "desc"
)
View Source
const (
	Owner  = "owner"
	Admin  = "admin"
	Member = "member"
	Left   = "left"
	Self   = "self"
	Banned = "banned"
)
View Source
const (
	SUCCESS = "success"
	FAILURE = "failure"
	INVITED = "invited"
)
View Source
const InviteMessageTemplate = `` /* 227-byte string literal not displayed */

Variables

View Source
var Roles = map[string]string{
	Admin:  "Admin",
	Member: "Member",
	Owner:  "Owner",

	Self:   "Self",
	Left:   "Left",
	Banned: "Banned",
}

Functions

func GetOffsetLinksForPGParams

func GetOffsetLinksForPGParams(r *http.Request, p pgdb.OffsetPageParams) *resources.Links

Types

type Chat

type Chat struct {
	Title         string  `json:"title" db:"title" structs:"title"`
	Id            int64   `json:"id" db:"id" structs:"id"`
	AccessHash    *int64  `json:"access_hash" db:"access_hash" structs:"access_hash"`
	MembersAmount int64   `json:"members_amount" db:"members_amount" structs:"members_amount"`
	PhotoName     *string `json:"photo_name" db:"photo_name" structs:"photo_name"`
	PhotoLink     *string `json:"photo_link" db:"photo_link" structs:"photo_link"`
}

type Chats

type Chats interface {
	New() Chats

	Upsert(chat Chat) error
	Delete() error
	Get() (*Chat, error)
	Select() ([]Chat, error)

	FilterByTitles(titles ...string) Chats
	FilterByIds(ids ...int64) Chats
	FilterByAccessHash(accessHash *int64) Chats
}
type Link struct {
	Id   int64  `db:"id" structs:"-"`
	Link string `db:"link" structs:"link"`
}
type Links interface {
	New() Links

	Insert(link Link) error
	Delete() error
	Get() (*Link, error)
	Select() ([]Link, error)

	FilterByLinks(links ...string) Links
}

type MessageInfo

type MessageInfo struct {
	Data            map[string]interface{}
	MessageTemplate string
	User            User
}

type ModulePayload

type ModulePayload struct {
	RequestId string `json:"request_id"`
	UserId    string `json:"user_id"`
	Action    string `json:"action"`

	//other fields that are required for module
	Link                string   `json:"link"`
	SubmoduleId         int64    `json:"submodule_id"`
	SubmoduleAccessHash *int64   `json:"submodule_access_hash"`
	Links               []string `json:"links"`
	Username            *string  `json:"username"`
	Phone               *string  `json:"phone"`
	AccessLevel         string   `json:"access_level"`
}

type ModuleRequest

type ModuleRequest struct {
	ID            string    `db:"id" structs:"id"`
	UserID        int64     `db:"user_id" structs:"user_id"`
	Module        string    `db:"module" structs:"module"`
	Payload       string    `db:"payload" structs:"payload"`
	CreatedAt     time.Time `db:"created_at" structs:"created_at"`
	RequestStatus string    `db:"request_status" structs:"request_status"`
	Error         string    `db:"error" structs:"error"`
}

type OrderType

type OrderType string

OrderType - represents sorting order of the query

const (
	// OrderAsc - ascending order
	OrderAsc OrderType = "asc"
	// OrderDesc - descending order
	OrderDesc OrderType = "desc"
)

func (OrderType) Invert

func (o OrderType) Invert() OrderType

Invert - inverts order by

type Permission

type Permission struct {
	RequestId           string    `json:"request_id" db:"request_id" structs:"request_id"`
	TelegramId          int64     `json:"telegram_id" db:"telegram_id" structs:"telegram_id"`
	AccessLevel         string    `json:"access_level" db:"access_level" structs:"access_level"`
	Link                string    `json:"link" db:"link" structs:"link"`
	SubmoduleId         int64     `json:"submodule_id" db:"submodule_id" structs:"submodule_id"`
	SubmoduleAccessHash *int64    `json:"submodule_access_hash" db:"submodule_access_hash" structs:"submodule_access_hash"`
	CreatedAt           time.Time `json:"created_at" db:"created_at" structs:"created_at"`
	UpdatedAt           time.Time `json:"updated_at" db:"updated_at" structs:"-"`
	*User               `structs:",omitempty"`
}

type Permissions

type Permissions interface {
	New() Permissions

	Upsert(permission Permission) error
	UpdateAccessLevel(permission Permission) error
	Delete() error
	Select() ([]Permission, error)
	Get() (*Permission, error)

	FilterByTelegramIds(telegramIds ...int64) Permissions
	FilterByLinks(links ...string) Permissions
	FilterByGreaterTime(time time.Time) Permissions
	FilterByLowerTime(time time.Time) Permissions
	SearchBy(search string) Permissions

	WithUsers() Permissions
	FilterByUserIds(userIds ...int64) Permissions

	Count() Permissions
	CountWithUsers() Permissions
	GetTotalCount() (int64, error)

	Page(pageParams pgdb.OffsetPageParams) Permissions
}

type Response

type Response struct {
	ID          string          `json:"id" db:"id" structs:"id"`
	Status      string          `json:"status" db:"status" structs:"status"`
	Error       *string         `json:"error,omitempty" db:"error,omitempty" structs:"error,omitempty"`
	Description *string         `json:"description,omitempty" db:"description,omitempty" structs:"description,omitempty"`
	Payload     json.RawMessage `json:"payload" db:"payload" structs:"payload"`
	CreatedAt   string          `json:"created_at" db:"created_at" structs:"-"`
}

type Responses

type Responses interface {
	New() Responses

	Insert(response Response) error
	Get() (*Response, error)
	Select() ([]Response, error)
	Delete() error

	FilterByIds(ids ...string) Responses
}

type UnverifiedPayload

type UnverifiedPayload struct {
	Action string           `json:"action"`
	Users  []UnverifiedUser `json:"users"`
}

type UnverifiedUser

type UnverifiedUser struct {
	CreatedAt time.Time `json:"created_at"`
	Module    string    `json:"module"`
	Submodule string    `json:"submodule"`
	ModuleId  string    `json:"module_id"`
	Email     *string   `json:"email,omitempty"`
	Name      *string   `json:"name,omitempty"`
	Phone     *string   `json:"phone,omitempty"`
	Username  *string   `json:"username,omitempty"`
}

type User

type User struct {
	Id         *int64    `json:"-" db:"id" structs:"id,omitempty"`
	Username   *string   `json:"username" db:"username" structs:"username,omitempty"`
	Phone      *string   `json:"phone" db:"phone" structs:"phone,omitempty"`
	FirstName  string    `json:"first_name" db:"first_name" structs:"first_name"`
	LastName   string    `json:"last_name" db:"last_name" structs:"last_name"`
	TelegramId int64     `json:"telegram_id" db:"telegram_id" structs:"telegram_id"`
	AccessHash int64     `json:"access_hash" db:"access_hash" structs:"access_hash"`
	CreatedAt  time.Time `json:"created_at" db:"created_at" structs:"-"`
	UpdatedAt  time.Time `json:"updated_at" db:"updated_at" structs:"-"`
	Module     string    `json:"module" db:"-" structs:"-"`
	Submodule  *string   `json:"-" db:"-" structs:"-"`
	// fields to create permission
	AccessLevel string `json:"-" db:"-" structs:"-"`
}

type Users

type Users interface {
	New() Users

	Upsert(user User) error
	Delete() error
	Select() ([]User, error)
	Get() (*User, error)

	FilterByLowerTime(time time.Time) Users
	FilterById(id *int64) Users
	FilterByTelegramIds(telegramIds ...int64) Users
	FilterByUsername(username string) Users
	FilterByPhone(phone string) Users
	SearchBy(search string) Users

	Count() Users
	GetTotalCount() (int64, error)

	Page(pageParams pgdb.OffsetPageParams) Users
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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