model

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileItem                 SearchItemType = "FILE"
	DirectoryItem            SearchItemType = "DIRECTORY"
	DefaultSearchResultLimit int            = 20
)
View Source
const BucketEncryptionKeyLength = 32 + 16 + 32

32 bytes aes key + 16 bytes salt/IV + 32 bytes HMAC key

Variables

This section is empty.

Functions

func GetAllCollectionConfigs added in v0.0.30

func GetAllCollectionConfigs() []db.CollectionConfig

func GetBucketCollectionConfig added in v0.0.30

func GetBucketCollectionConfig() db.CollectionConfig

func GetMirrorFileCollectionConfig added in v0.0.30

func GetMirrorFileCollectionConfig() db.CollectionConfig

func GetReceivedFileCollectionConfig added in v0.0.30

func GetReceivedFileCollectionConfig() db.CollectionConfig

func GetSentFileCollectionConfig added in v0.0.34

func GetSentFileCollectionConfig() db.CollectionConfig

func GetSharedPublicKeyCollectionConfig added in v0.0.30

func GetSharedPublicKeyCollectionConfig() db.CollectionConfig

func New

func New(
	st store.Store,
	kc keychain.Keychain,
	threads *threadsClient.Client,
	ht *threadsClient.Client,
	hubAuth hub.HubAuth,
	cfg config.Config,
	netc *nc.Client,
	hnetc *nc.Client,
	shouldForceRestore bool,
	search search.FilesSearchEngine,
) *model

Types

type BucketSchema

type BucketSchema struct {
	ID            core.InstanceID `json:"_id"`
	Slug          string          `json:"slug"`
	Backup        bool            `json:"backup"`
	EncryptionKey []byte          `json:"hub_key"`
	DbID          string
	*MirrorBucketSchema
}

type MirrorBucketSchema

type MirrorBucketSchema struct {
	RemoteDbID       string `json:"remoteDbId"`
	RemoteBucketKey  string `json:"remoteBucketKey"`
	HubAddr          string `json:"HubAddr"`
	RemoteBucketSlug string `json:"remoteBucketSlug"`
}

type MirrorFileSchema

type MirrorFileSchema struct {
	ID                core.InstanceID `json:"_id"`
	Path              string          `json:"path"`
	BucketSlug        string          `json:"bucket_slug"`
	Backup            bool            `json:"backup"`
	Shared            bool            `json:"shared"`
	BackupInProgress  bool            `json:"backupInProgress"`
	RestoreInProgress bool            `json:"restoreInProgress"`
	DbID              string
}

type Model

type Model interface {
	CreateBucket(ctx context.Context, bucketSlug, dbID string) (*BucketSchema, error)
	UpsertBucket(ctx context.Context, bucketSlug, dbID string) (*BucketSchema, error)
	BucketBackupToggle(ctx context.Context, bucketSlug string, backup bool) (*BucketSchema, error)
	FindBucket(ctx context.Context, bucketSlug string) (*BucketSchema, error)
	ListBuckets(ctx context.Context) ([]*BucketSchema, error)
	CreateReceivedFileViaInvitation(
		ctx context.Context,
		file domain.FullPath,
		invitationId string,
		accepted bool,
		key []byte,
		sharedBy string,
	) (*ReceivedFileSchema, error)
	CreateReceivedFileViaPublicLink(
		ctx context.Context,
		ipfsHash string,
		password string,
		filename string,
		filesize string,
		accepted bool,
	) (*ReceivedFileSchema, error)
	CreateSentFileViaInvitation(
		ctx context.Context,
		file domain.FullPath,
		invitationId string,
		key []byte,
	) (*SentFileSchema, error)
	FindReceivedFile(ctx context.Context, remoteDbID, bucket, path string) (*ReceivedFileSchema, error)
	FindPublicLinkReceivedFile(ctx context.Context, ipfsHash string) (*ReceivedFileSchema, error)
	FindSentFile(ctx context.Context, remoteDbID, bucket, path string) (*SentFileSchema, error)
	CreateSharedPublicKey(ctx context.Context, pubKey string) (*SharedPublicKeySchema, error)
	ListSharedPublicKeys(ctx context.Context) ([]*SharedPublicKeySchema, error)
	CreateMirrorBucket(ctx context.Context, bucketSlug string, mirrorBucket *MirrorBucketSchema) (*BucketSchema, error)
	FindMirrorFileByPathAndBucketSlug(ctx context.Context, path, bucketSlug string) (*MirrorFileSchema, error)
	CreateMirrorFile(ctx context.Context, mirrorFile *domain.MirrorFile) (*MirrorFileSchema, error)
	UpdateMirrorFile(ctx context.Context, mirrorFile *MirrorFileSchema) (*MirrorFileSchema, error)
	ListReceivedFiles(ctx context.Context, accepted bool, seek string, limit int) ([]*ReceivedFileSchema, error)
	ListSentFiles(ctx context.Context, seek string, limit int) ([]*SentFileSchema, error)
	ListReceivedPublicFiles(ctx context.Context, cidHash string, accepted bool) ([]*ReceivedFileSchema, error)
	DeleteReceivedFiles(ctx context.Context, paths []domain.FullPath, keys [][]byte) error
	FindMirrorFileByPaths(ctx context.Context, paths []string) (map[string]*MirrorFileSchema, error)
	FindReceivedFilesByIds(ctx context.Context, ids []string) ([]*ReceivedFileSchema, error)
	InitSearchIndexCollection(ctx context.Context) error
	UpdateSearchIndexRecord(
		ctx context.Context,
		name, path string,
		itemType SearchItemType,
		bucketSlug, dbId string,
	) (*SearchIndexRecord, error)
	QuerySearchIndex(ctx context.Context, query string) ([]*SearchIndexRecord, error)
	DeleteSearchIndexRecord(ctx context.Context, name, path, bucketSlug, dbId string) error
}

type ReceivedFileSchema

type ReceivedFileSchema struct {
	ID        core.InstanceID `json:"_id"`
	Accepted  bool            `json:"accepted"`
	CreatedAt int64           `json:"created_at"`
	ReceivedFileViaInvitationSchema
	ReceivedFileViaPublicLinkSchema
}

ReceivedFileSchema represents data of files shared with a user A file is shared with a user either by direct invite to the user or through a publicly accessible link

func (ReceivedFileSchema) IsPublicLinkReceived added in v0.0.26

func (r ReceivedFileSchema) IsPublicLinkReceived() bool

type ReceivedFileViaInvitationSchema added in v0.0.26

type ReceivedFileViaInvitationSchema struct {
	DbID          string `json:"dbId"`
	Bucket        string `json:"bucket"`
	Path          string `json:"path"`
	InvitationId  string `json:"invitationId"`
	BucketKey     string `json:"bucketKey"`
	EncryptionKey []byte `json:"encryptionKey"`
	SharedBy      string `json:"sharedBy"`
}

type ReceivedFileViaPublicLinkSchema added in v0.0.26

type ReceivedFileViaPublicLinkSchema struct {
	PublicIpfsHash string `json:"publicIpfsHash"`
	FilePassword   string `json:"filePassword"`
	FileName       string `json:"fileName"`
	FileSize       string `json:"fileSize"`
}

type SearchIndexRecord added in v0.0.30

type SearchIndexRecord search.IndexRecord

type SearchItemType added in v0.0.30

type SearchItemType string

type SentFileSchema added in v0.0.34

type SentFileSchema struct {
	ID        core.InstanceID `json:"_id"`
	CreatedAt int64           `json:"created_at"`
	SentFileViaInvitationSchema
}

SentFileSchema represents data of files shared by the user

func (*SentFileSchema) ReceivedFileSchema added in v0.0.34

func (sf *SentFileSchema) ReceivedFileSchema() *ReceivedFileSchema

XXX: this is to reuse the builders in the sharing.go

type SentFileViaInvitationSchema added in v0.0.34

type SentFileViaInvitationSchema struct {
	DbID          string `json:"dbId"`
	Bucket        string `json:"bucket"`
	Path          string `json:"path"`
	InvitationId  string `json:"invitationId"`
	BucketKey     string `json:"bucketKey"`
	EncryptionKey []byte `json:"encryptionKey"`
}

type SharedPublicKeySchema

type SharedPublicKeySchema struct {
	ID        core.InstanceID `json:"_id"`
	DbID      string          `json:"dbId"`
	PublicKey string          `json:"public_key"`
	UpdatedAt int64           `json:"updated_at"`
	CreatedAt int64           `json:"created_at"`
}

Jump to

Keyboard shortcuts

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