Documentation ¶
Index ¶
- Constants
- func MakeOwner(u *User)
- type AccessService
- type Album
- func (a *Album) GetCover() ContentId
- func (a *Album) GetMedias() []ContentId
- func (a *Album) GetName() string
- func (a *Album) GetOwner() Username
- func (a *Album) GetPrimaryColor() string
- func (a *Album) ID() AlbumId
- func (a *Album) RemoveMedia(toRemoveIds ...ContentId)
- func (a *Album) SetCover(cover ContentId, color1, color2 string)
- type AlbumId
- type AlbumService
- type AlbumShare
- func (s *AlbumShare) AddUsers(usernames []Username)
- func (s *AlbumShare) GetAccessors() []Username
- func (s *AlbumShare) GetItemId() string
- func (s *AlbumShare) GetOwner() Username
- func (s *AlbumShare) GetShareType() ShareType
- func (s *AlbumShare) ID() ShareId
- func (s *AlbumShare) IsEnabled() bool
- func (s *AlbumShare) IsPublic() bool
- func (s *AlbumShare) LastUpdated() time.Time
- func (s *AlbumShare) MarshalBSON() ([]byte, error)
- func (s *AlbumShare) RemoveUsers(usernames []Username)
- func (s *AlbumShare) SetAccessors(usernames []Username)
- func (s *AlbumShare) SetEnabled(enable bool)
- func (s *AlbumShare) SetItemId(albumId string)
- func (s *AlbumShare) SetPublic(pub bool)
- func (s *AlbumShare) UnmarshalBSON(bs []byte) error
- func (s *AlbumShare) UpdatedNow()
- type ApiKey
- type BackupCoreFileMeta
- type BackupMeta
- type BasicCaster
- type Broadcaster
- type Client
- type ClientId
- type ClientManager
- type ClientType
- type ContentId
- type FileCaster
- type FileChunk
- type FileService
- type FileShare
- func (s *FileShare) AddUsers(usernames []Username)
- func (s *FileShare) GetAccessors() []Username
- func (s *FileShare) GetItemId() string
- func (s *FileShare) GetOwner() Username
- func (s *FileShare) GetShareType() ShareType
- func (s *FileShare) ID() ShareId
- func (s *FileShare) IsEnabled() bool
- func (s *FileShare) IsPublic() bool
- func (s *FileShare) IsWormhole() bool
- func (s *FileShare) LastUpdated() time.Time
- func (s *FileShare) RemoveUsers(usernames []Username)
- func (s *FileShare) SetAccessors(usernames []Username)
- func (s *FileShare) SetEnabled(enable bool)
- func (s *FileShare) SetItemId(fileId string)
- func (s *FileShare) SetPublic(pub bool)
- func (s *FileShare) UpdatedNow()
- type FileUploadProgress
- type FsStatMeta
- type HashFileMeta
- type Hasher
- type Instance
- func (wi *Instance) GetAddress() (string, error)
- func (wi *Instance) GetName() string
- func (wi *Instance) GetReportedRole() ServerRole
- func (wi *Instance) GetRole() ServerRole
- func (wi *Instance) GetUsingKey() WeblensApiKey
- func (wi *Instance) IsCore() bool
- func (wi *Instance) IsLocal() bool
- func (wi *Instance) ServerId() InstanceId
- func (wi *Instance) SetAddress(address string) error
- func (wi *Instance) SetReportedRole(role ServerRole)
- func (wi *Instance) SetRole(role ServerRole)
- func (wi *Instance) SetServerId(id InstanceId)
- func (wi *Instance) SetUsingKey(key WeblensApiKey)
- func (wi *Instance) SocketType() string
- type InstanceId
- type InstanceService
- type Media
- func (m *Media) AddFile(f *fileTree.WeblensFileImpl)
- func (m *Media) FmtCacheFileName(quality MediaQuality, pageNum int) string
- func (m *Media) GetCreateDate() time.Time
- func (m *Media) GetFiles() []fileTree.FileId
- func (m *Media) GetHighresCacheFiles(pageNum int) *fileTree.WeblensFileImpl
- func (m *Media) GetLowresCacheFile() *fileTree.WeblensFileImpl
- func (m *Media) GetOwner() Username
- func (m *Media) GetPageCount() int
- func (m *Media) GetVideoLength() int
- func (m *Media) ID() ContentId
- func (m *Media) IsEnabled() bool
- func (m *Media) IsHidden() bool
- func (m *Media) IsImported() bool
- func (m *Media) MarshalJSON() ([]byte, error)
- func (m *Media) SetContentId(id ContentId)
- func (m *Media) SetCreateDate(t time.Time)
- func (m *Media) SetEnabled(e bool)
- func (m *Media) SetHighresCacheFiles(highresFile *fileTree.WeblensFileImpl, pageNum int)
- func (m *Media) SetImported(i bool)
- func (m *Media) SetLowresCacheFile(thumb *fileTree.WeblensFileImpl)
- func (m *Media) SetOwner(owner Username)
- func (m *Media) UnmarshalBSON(bs []byte) error
- func (m *Media) UnmarshalJSON(bs []byte) error
- type MediaQuality
- type MediaService
- type MediaType
- func (mt MediaType) FriendlyName() string
- func (mt MediaType) GetMime() string
- func (mt MediaType) GetThumbExifKey() string
- func (mt MediaType) IsDisplayable() bool
- func (mt MediaType) IsMime(mime string) bool
- func (mt MediaType) IsMultiPage() bool
- func (mt MediaType) IsRaw() bool
- func (mt MediaType) IsSupported() bool
- func (mt MediaType) IsVideo() bool
- func (mt MediaType) SupportsImgRecog() bool
- type MediaTypeService
- type MoveMeta
- type RestoreCoreMeta
- type ScanMeta
- type Server
- type ServerRole
- type ServicePack
- type Share
- type ShareId
- type ShareService
- type ShareType
- type SocketUser
- type StartupTask
- type SubId
- type Subscription
- type TaskDispatcher
- type TaskStage
- type TaskStages
- type TaskSubscriber
- type Token
- type UploadFilesMeta
- type User
- func (u *User) CheckLogin(password string) bool
- func (u *User) GetUsername() Username
- func (u *User) IsActive() bool
- func (u *User) IsAdmin() bool
- func (u *User) IsOwner() bool
- func (u *User) IsPublic() bool
- func (u *User) IsSystemUser() bool
- func (u *User) SetHomeFolder(f *fileTree.WeblensFileImpl)
- func (u *User) SetTrashFolder(f *fileTree.WeblensFileImpl)
- func (u *User) SocketType() string
- func (u *User) UnmarshalJSON(data []byte) error
- type UserService
- type Username
- type VideoStreamer
- func (vs *VideoStreamer) Encode(f *fileTree.WeblensFileImpl) *VideoStreamer
- func (vs *VideoStreamer) Err() error
- func (vs *VideoStreamer) GetChunk(chunkName string) (*os.File, error)
- func (vs *VideoStreamer) GetEncodeDir() string
- func (vs *VideoStreamer) GetListFile() ([]byte, error)
- func (vs *VideoStreamer) IsTranscoding() bool
- type WeblensApiKey
- type WsAction
- type WsC
- type WsClient
- func (wsc *WsClient) AddSubscription(sub Subscription)
- func (wsc *WsClient) ClientType() ClientType
- func (wsc *WsClient) Disconnect()
- func (wsc *WsClient) Error(err error)
- func (wsc *WsClient) GetClientId() ClientId
- func (wsc *WsClient) GetRemote() *Instance
- func (wsc *WsClient) GetShortId() ClientId
- func (wsc *WsClient) GetSubscriptions() iter.Seq[Subscription]
- func (wsc *WsClient) GetUser() *User
- func (wsc *WsClient) IsOpen() bool
- func (wsc *WsClient) PushFileUpdate(updatedFile *fileTree.WeblensFileImpl, media *Media)
- func (wsc *WsClient) PushPoolUpdate(pool task.Pool, event string, result task.TaskResult)
- func (wsc *WsClient) PushTaskUpdate(task *task.Task, event string, result task.TaskResult)
- func (wsc *WsClient) PushWeblensEvent(eventTag string, content ...WsC)
- func (wsc *WsClient) Raw(msg any) error
- func (wsc *WsClient) ReadOne() (int, []byte, error)
- func (wsc *WsClient) RemoveSubscription(key SubId)
- func (wsc *WsClient) Send(msg WsResponseInfo) error
- func (wsc *WsClient) SubLock()
- func (wsc *WsClient) SubUnlock()
- type WsR
- type WsRequestInfo
- type WsResponseInfo
- type ZipMeta
Constants ¶
View Source
const ( BackupCompleteEvent = "backupComplete" BackupFailedEvent = "backupFailed" BackupProgressEvent = "backupProgress" CopyFileCompleteEvent = "copyFileComplete" CopyFileFailedEvent = "copyFileFailed" CopyFileStartedEvent = "copyFileStarted" ErrorEvent = "error" FileCreatedEvent = "fileCreated" FileDeletedEvent = "fileDeleted" FileMovedEvent = "fileMoved" FileScanCompleteEvent = "fileScanComplete" FileUpdatedEvent = "fileUpdated" FilesDeletedEvent = "filesDeleted" FilesMovedEvent = "filesMoved" FilesUpdatedEvent = "filesUpdated" FolderScanCompleteEvent = "folderScanComplete" PoolCancelledEvent = "poolCancelled" PoolCompleteEvent = "poolComplete" PoolCreatedEvent = "poolCreated" RemoteConnectionChangedEvent = "remoteConnectionChanged" RestoreCompleteEvent = "restoreComplete" RestoreFailedEvent = "restoreFailed" RestoreProgressEvent = "restoreProgress" RestoreStartedEvent = "restoreStarted" ScanDirectoryProgressEvent = "scanDirectoryProgress" ServerGoingDownEvent = "goingDown" StartupProgressEvent = "startupProgress" TaskCanceledEvent = "taskCanceled" TaskCompleteEvent = "taskComplete" TaskCreatedEvent = "taskCreated" TaskFailedEvent = "taskFailure" WeblensLoadedEvent = "weblensLoaded" ZipCompleteEvent = "zipComplete" ZipProgressEvent = "createZipProgress" )
View Source
const ( ScanDirectoryTask = "scan_directory" ScanFileTask = "scan_file" MoveFileTask = "move_file" UploadFilesTask = "write_file" CreateZipTask = "create_zip" GatherFsStatsTask = "gather_filesystem_stats" BackupTask = "do_backup" HashFileTask = "hash_file" CopyFileFromCoreTask = "copy_file_from_core" RestoreCoreTask = "restore_core" )
View Source
const ThumbnailHeight float32 = 500
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessService ¶
type AccessService interface { GenerateJwtToken(user *User) (token string, expires time.Time, err error) GetApiKey(key WeblensApiKey) (ApiKey, error) AddApiKey(key ApiKey) error GetUserFromToken(token string) (*User, error) DeleteApiKey(key WeblensApiKey) error GenerateApiKey(creator *User, local *Instance) (ApiKey, error) CanUserAccessFile(user *User, file *fileTree.WeblensFileImpl, share *FileShare) bool CanUserAccessAlbum(user *User, album *Album, share *AlbumShare) bool GetAllKeys(accessor *User) ([]ApiKey, error) GetAllKeysByServer(accessor *User, serverId InstanceId) ([]ApiKey, error) SetKeyUsedBy(key WeblensApiKey, server *Instance) error }
type Album ¶
type Album struct { Id AlbumId `bson:"_id"` Name string `bson:"name"` Owner Username `bson:"owner"` Medias []ContentId `bson:"medias"` Cover ContentId `bson:"cover"` PrimaryColor string `bson:"primaryColor"` SecondaryColor string `bson:"secondaryColor"` ShowOnTimeline bool `bson:"showOnTimeline"` }
func (*Album) GetPrimaryColor ¶
func (*Album) RemoveMedia ¶
type AlbumService ¶
type AlbumService interface { Init() error Size() int Get(id AlbumId) *Album Add(album *Album) error Del(id AlbumId) error GetAllByUser(u *User) ([]*Album, error) GetAlbumMedias(album *Album) iter.Seq[*Media] RenameAlbum(album *Album, newName string) error SetAlbumCover(albumId AlbumId, cover *Media) error AddMediaToAlbum(album *Album, media ...*Media) error RemoveMediaFromAlbum(album *Album, mediaIds ...ContentId) error RemoveMediaFromAny(ContentId) error }
type AlbumShare ¶
type AlbumShare struct { // @name AlbumShare}
func NewAlbumShare ¶
func NewAlbumShare( a *Album, owner *User, accessors []*User, public bool, ) *AlbumShare
func (*AlbumShare) AddUsers ¶
func (s *AlbumShare) AddUsers(usernames []Username)
func (*AlbumShare) GetAccessors ¶
func (s *AlbumShare) GetAccessors() []Username
func (*AlbumShare) GetItemId ¶
func (s *AlbumShare) GetItemId() string
func (*AlbumShare) GetOwner ¶
func (s *AlbumShare) GetOwner() Username
func (*AlbumShare) GetShareType ¶
func (s *AlbumShare) GetShareType() ShareType
func (*AlbumShare) ID ¶
func (s *AlbumShare) ID() ShareId
func (*AlbumShare) IsEnabled ¶
func (s *AlbumShare) IsEnabled() bool
func (*AlbumShare) IsPublic ¶
func (s *AlbumShare) IsPublic() bool
func (*AlbumShare) LastUpdated ¶
func (s *AlbumShare) LastUpdated() time.Time
func (*AlbumShare) MarshalBSON ¶
func (s *AlbumShare) MarshalBSON() ([]byte, error)
func (*AlbumShare) RemoveUsers ¶
func (s *AlbumShare) RemoveUsers(usernames []Username)
func (*AlbumShare) SetAccessors ¶
func (s *AlbumShare) SetAccessors(usernames []Username)
func (*AlbumShare) SetEnabled ¶
func (s *AlbumShare) SetEnabled(enable bool)
func (*AlbumShare) SetItemId ¶
func (s *AlbumShare) SetItemId(albumId string)
func (*AlbumShare) SetPublic ¶
func (s *AlbumShare) SetPublic(pub bool)
func (*AlbumShare) UnmarshalBSON ¶
func (s *AlbumShare) UnmarshalBSON(bs []byte) error
func (*AlbumShare) UpdatedNow ¶
func (s *AlbumShare) UpdatedNow()
type ApiKey ¶
type ApiKey struct { Id primitive.ObjectID `bson:"_id"` Key WeblensApiKey `bson:"key"` Owner Username `bson:"owner"` CreatedTime time.Time `bson:"createdTime"` RemoteUsing InstanceId `bson:"remoteUsing"` CreatedBy InstanceId `bson:"createdBy"` }
type BackupCoreFileMeta ¶
type BackupCoreFileMeta struct { ProxyFileService FileService FileService FileService File *fileTree.WeblensFileImpl Caster Broadcaster Core *Instance Filename string }
func (BackupCoreFileMeta) FormatToResult ¶
func (m BackupCoreFileMeta) FormatToResult() task.TaskResult
func (BackupCoreFileMeta) JobName ¶
func (m BackupCoreFileMeta) JobName() string
func (BackupCoreFileMeta) MetaString ¶
func (m BackupCoreFileMeta) MetaString() string
func (BackupCoreFileMeta) Verify ¶
func (m BackupCoreFileMeta) Verify() error
type BackupMeta ¶
type BackupMeta struct { Core *Instance FileService FileService UserService UserService WebsocketService ClientManager InstanceService InstanceService TaskService task.TaskService AccessService AccessService Caster Broadcaster }
func (BackupMeta) FormatToResult ¶
func (m BackupMeta) FormatToResult() task.TaskResult
func (BackupMeta) JobName ¶
func (m BackupMeta) JobName() string
func (BackupMeta) MetaString ¶
func (m BackupMeta) MetaString() string
func (BackupMeta) Verify ¶
func (m BackupMeta) Verify() error
type BasicCaster ¶
type BasicCaster interface { PushWeblensEvent(eventTag string, content ...WsC) PushFileUpdate(updatedFile *fileTree.WeblensFileImpl, media *Media) PushTaskUpdate(task *task.Task, event string, result task.TaskResult) PushPoolUpdate(pool task.Pool, event string, result task.TaskResult) }
type Broadcaster ¶
type Broadcaster interface { BasicCaster PushFileCreate(newFile *fileTree.WeblensFileImpl) PushFileMove(preMoveFile *fileTree.WeblensFileImpl, postMoveFile *fileTree.WeblensFileImpl) PushFilesMove(preMoveParentId, postMoveParentId fileTree.FileId, files []*fileTree.WeblensFileImpl) PushFileDelete(deletedFile *fileTree.WeblensFileImpl) PushFilesDelete(deletedFiles []*fileTree.WeblensFileImpl) PushFilesUpdate(files []*fileTree.WeblensFileImpl, medias []*Media) Enable() Disable() IsEnabled() bool IsBuffered() bool FolderSubToTask(folder fileTree.FileId, taskId task.Id) // UnsubTask(task *task.Task) DisableAutoFlush() AutoFlushEnable() Flush() Relay(msg WsResponseInfo) // Close flush, release the auto-flusher, and disable the caster Close() }
type Client ¶
type Client interface { BasicCaster IsOpen() bool ReadOne() (int, []byte, error) GetSubscriptions() iter.Seq[Subscription] GetClientId() ClientId GetShortId() ClientId SubLock() SubUnlock() AddSubscription(sub Subscription) GetUser() *User GetRemote() *Instance Error(error) }
type ClientManager ¶
type ClientManager interface { ClientConnect(conn *websocket.Conn, user *User) *WsClient ClientDisconnect(c *WsClient) RemoteConnect(conn *websocket.Conn, remote *Instance) *WsClient Send(msg WsResponseInfo) GetSubscribers(st WsAction, key SubId) (clients []*WsClient) GetClientByUsername(username Username) *WsClient GetClientByServerId(id InstanceId) *WsClient GetAllClients() []*WsClient GetConnectedAdmins() []*WsClient // FolderSubToPool(folderId fileTree.FileId, poolId task.Id) // TaskSubToPool(taskId task.Id, poolId task.Id) FolderSubToTask(folderId fileTree.FileId, taskId task.Id) UnsubTask(taskId task.Id) Subscribe(c *WsClient, key SubId, action WsAction, subTime time.Time, share Share) ( complete bool, results map[task.TaskResultKey]any, err error, ) Unsubscribe(c *WsClient, key SubId, unSubTime time.Time) error }
type ClientType ¶
type ClientType string
const ( WebClient ClientType = "webClient" RemoteClient ClientType = "remoteClient" )
type FileCaster ¶
type FileCaster interface { PushFileUpdate(updatedFile *fileTree.WeblensFileImpl, media *Media) PushFilesUpdate(updatedFiles []*fileTree.WeblensFileImpl, medias []*Media) PushTaskUpdate(task *task.Task, event string, result task.TaskResult) PushPoolUpdate(pool task.Pool, event string, result task.TaskResult) PushFileCreate(newFile *fileTree.WeblensFileImpl) PushFileMove(preMoveFile *fileTree.WeblensFileImpl, postMoveFile *fileTree.WeblensFileImpl) PushFilesMove(preMoveParentId, postMoveParentId fileTree.FileId, files []*fileTree.WeblensFileImpl) PushFileDelete(deletedFile *fileTree.WeblensFileImpl) PushFilesDelete(deletedFiles []*fileTree.WeblensFileImpl) Close() Flush() }
type FileService ¶
type FileService interface { Size(treeAlias string) int64 AddTree(tree fileTree.FileTree) GetFileTreeByName(treeName string) fileTree.FileTree GetFileByTree(id fileTree.FileId, treeAlias string) (*fileTree.WeblensFileImpl, error) GetFileByContentId(contentId ContentId) (*fileTree.WeblensFileImpl, error) GetFiles(ids []fileTree.FileId) ([]*fileTree.WeblensFileImpl, []fileTree.FileId, error) GetFileSafe(id fileTree.FileId, accessor *User, share *FileShare) (*fileTree.WeblensFileImpl, error) PathToFile(searchPath string) (*fileTree.WeblensFileImpl, error) UserPathToFile(searchPath string, user *User) (*fileTree.WeblensFileImpl, error) CreateFile(parent *fileTree.WeblensFileImpl, filename string, event *fileTree.FileEvent, caster FileCaster) (*fileTree.WeblensFileImpl, error) CreateFolder(parent *fileTree.WeblensFileImpl, folderName string, event *fileTree.FileEvent, caster FileCaster) (*fileTree.WeblensFileImpl, error) CreateUserHome(user *User) error NewBackupFile(lt *fileTree.Lifetime) (*fileTree.WeblensFileImpl, error) GetFileOwner(file *fileTree.WeblensFileImpl) *User IsFileInTrash(file *fileTree.WeblensFileImpl) bool MoveFiles(files []*fileTree.WeblensFileImpl, destFolder *fileTree.WeblensFileImpl, treeName string, caster FileCaster) error RenameFile(file *fileTree.WeblensFileImpl, newName string, caster FileCaster) error MoveFilesToTrash(file []*fileTree.WeblensFileImpl, mover *User, share *FileShare, caster FileCaster) error ReturnFilesFromTrash(files []*fileTree.WeblensFileImpl, caster FileCaster) error DeleteFiles(files []*fileTree.WeblensFileImpl, treeName string, caster FileCaster) error RestoreFiles(ids []fileTree.FileId, newParent *fileTree.WeblensFileImpl, restoreTime time.Time, caster FileCaster) error RestoreHistory(lifetimes []*fileTree.Lifetime) error ReadFile(f *fileTree.WeblensFileImpl) (io.ReadCloser, error) GetMediaCacheByFilename(filename string) (*fileTree.WeblensFileImpl, error) NewCacheFile(media *Media, quality MediaQuality, pageNum int) (*fileTree.WeblensFileImpl, error) DeleteCacheFile(file fileTree.WeblensFile) error GetFolderCover(folder *fileTree.WeblensFileImpl) (ContentId, error) SetFolderCover(folderId fileTree.FileId, coverId ContentId) error AddTask(f *fileTree.WeblensFileImpl, t *task.Task) error RemoveTask(f *fileTree.WeblensFileImpl, t *task.Task) error GetTasks(f *fileTree.WeblensFileImpl) []*task.Task GetJournalByTree(treeName string) fileTree.Journal ResizeDown(file *fileTree.WeblensFileImpl, caster FileCaster) error ResizeUp(file *fileTree.WeblensFileImpl, caster FileCaster) error NewZip(zipName string, owner *User) (*fileTree.WeblensFileImpl, error) GetZip(id fileTree.FileId) (*fileTree.WeblensFileImpl, error) }
type FileShare ¶
type FileShare struct {}
func NewFileShare ¶
func (*FileShare) GetAccessors ¶
func (*FileShare) GetShareType ¶
func (*FileShare) IsWormhole ¶
func (*FileShare) LastUpdated ¶
func (*FileShare) RemoveUsers ¶
func (*FileShare) SetAccessors ¶
func (*FileShare) SetEnabled ¶
func (*FileShare) UpdatedNow ¶
func (s *FileShare) UpdatedNow()
type FileUploadProgress ¶
type FsStatMeta ¶
type FsStatMeta struct {
RootDir *fileTree.WeblensFileImpl
}
func (FsStatMeta) FormatToResult ¶
func (m FsStatMeta) FormatToResult() task.TaskResult
func (FsStatMeta) JobName ¶
func (m FsStatMeta) JobName() string
func (FsStatMeta) MetaString ¶
func (m FsStatMeta) MetaString() string
func (FsStatMeta) Verify ¶
func (m FsStatMeta) Verify() error
type HashFileMeta ¶
type HashFileMeta struct { File *fileTree.WeblensFileImpl Caster Broadcaster }
func (HashFileMeta) FormatToResult ¶
func (m HashFileMeta) FormatToResult() task.TaskResult
func (HashFileMeta) JobName ¶
func (m HashFileMeta) JobName() string
func (HashFileMeta) MetaString ¶
func (m HashFileMeta) MetaString() string
func (HashFileMeta) Verify ¶
func (m HashFileMeta) Verify() error
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
func NewHasher ¶
func NewHasher(service task.TaskService, caster Broadcaster) *Hasher
type Instance ¶
type Instance struct { // The ID of the server in the local database DbId primitive.ObjectID `json:"-" bson:"_id"` // The ID of the server that is shared between all servers Id InstanceId `json:"id" bson:"instanceId"` Name string `json:"name" bson:"name"` // Only applies to "core" server entries. This is the apiKey that remote server is using to connect to local, // if local is core. If local is backup, then this is the key being used to connect to remote core UsingKey WeblensApiKey `json:"-" bson:"usingKey"` // Core or BackupServer Role ServerRole `json:"role" bson:"serverRole"` // If this server info represents this local server IsThisServer bool `json:"-" bson:"isThisServer"` // Address of the remote server, only if the instance is a core. // Not set for any remotes/backups on core server, as it IS the core Address string `json:"coreAddress" bson:"coreAddress"` // The ID of the server in which this remote instance is in reference from CreatedBy InstanceId `json:"createdBy" bson:"createdBy"` // The time of the latest backup, in milliseconds since epoch LastBackup int64 `json:"lastBackup" bson:"lastBackup"` // contains filtered or unexported fields }
An "Instance" is a single Weblens server. For clarity: Core vs Backup are absolute server roles, and each server will fit into one of these categories once initialized. Local vs Remote are RELATIVE terms, meaning one core servers "remote" is the backup servers "local".
func NewInstance ¶
func NewInstance( id InstanceId, name string, key WeblensApiKey, role ServerRole, isThisServer bool, address string, createdBy InstanceId, ) *Instance
func (*Instance) GetAddress ¶
func (*Instance) GetReportedRole ¶
func (wi *Instance) GetReportedRole() ServerRole
func (*Instance) GetRole ¶
func (wi *Instance) GetRole() ServerRole
func (*Instance) GetUsingKey ¶
func (wi *Instance) GetUsingKey() WeblensApiKey
func (*Instance) ServerId ¶
func (wi *Instance) ServerId() InstanceId
func (*Instance) SetAddress ¶
func (*Instance) SetReportedRole ¶
func (wi *Instance) SetReportedRole(role ServerRole)
func (*Instance) SetRole ¶
func (wi *Instance) SetRole(role ServerRole)
func (*Instance) SetServerId ¶
func (wi *Instance) SetServerId(id InstanceId)
func (*Instance) SetUsingKey ¶
func (wi *Instance) SetUsingKey(key WeblensApiKey)
func (*Instance) SocketType ¶
type InstanceId ¶
type InstanceId = string
type InstanceService ¶
type InstanceService interface { Size() int Get(dbId string) *Instance GetAllByOriginServer(serverId InstanceId) []*Instance GetByInstanceId(serverId InstanceId) *Instance Add(instance *Instance) error Del(dbId primitive.ObjectID) error GetLocal() *Instance GetCores() []*Instance GetRemotes() []*Instance InitCore(serverName string) error InitBackup(name, coreAddr string, key WeblensApiKey) error SetLastBackup(id InstanceId, time time.Time) error AttachRemoteCore(coreAddr string, key string) (*Instance, error) ResetAll() error }
type Media ¶
type Media struct { MediaId primitive.ObjectID `bson:"_id" example:"5f9b3b3b7b4f3b0001b3b3b7"` // Hash of the file content, to ensure that the same files don't get duplicated ContentId ContentId `bson:"contentId"` // Slices of files whos content hash to the contentId FileIds []fileTree.FileId `bson:"fileIds"` CreateDate time.Time `bson:"createDate"` // User who owns the file that resulted in this media being created Owner Username `bson:"owner"` // Full-res image dimensions Width int `bson:"width"` Height int `bson:"height"` // Number of pages (typically 1, 0 in not a valid page count) PageCount int `bson:"pageCount"` // Total time, in milliseconds, of a video Duration int `bson:"duration"` // Mime-type key of the media MimeType string `bson:"mimeType"` // Tags from the ML image scan so searching for particular objects in the images can be done RecognitionTags []string `bson:"recognitionTags"` // If the media is hidden from the timeline // TODO - make this per user Hidden bool `bson:"hidden"` // If the media disabled. This can happen when the backing file(s) are deleted, // but the media stays behind because it can be re-used if needed. Enabled bool `bson:"enabled"` LikedBy []Username `bson:"likedBy"` // The rotation of the image from its original. Found from the exif data Rotate string // contains filtered or unexported fields }
func (*Media) AddFile ¶
func (m *Media) AddFile(f *fileTree.WeblensFileImpl)
func (*Media) FmtCacheFileName ¶
func (m *Media) FmtCacheFileName(quality MediaQuality, pageNum int) string
func (*Media) GetCreateDate ¶
func (*Media) GetHighresCacheFiles ¶
func (m *Media) GetHighresCacheFiles(pageNum int) *fileTree.WeblensFileImpl
func (*Media) GetLowresCacheFile ¶
func (m *Media) GetLowresCacheFile() *fileTree.WeblensFileImpl
func (*Media) GetPageCount ¶
func (*Media) GetVideoLength ¶
GetVideoLength returns the length of the media video, if it is a video. Duration is counted in milliseconds
func (*Media) IsImported ¶
func (*Media) MarshalJSON ¶
func (*Media) SetContentId ¶
func (*Media) SetCreateDate ¶
func (*Media) SetEnabled ¶
func (*Media) SetHighresCacheFiles ¶
func (m *Media) SetHighresCacheFiles(highresFile *fileTree.WeblensFileImpl, pageNum int)
func (*Media) SetImported ¶
func (*Media) SetLowresCacheFile ¶
func (m *Media) SetLowresCacheFile(thumb *fileTree.WeblensFileImpl)
func (*Media) UnmarshalBSON ¶
func (*Media) UnmarshalJSON ¶
type MediaQuality ¶
type MediaQuality string
const ( LowRes MediaQuality = "thumbnail" HighRes MediaQuality = "fullres" Video MediaQuality = "video" )
type MediaService ¶
type MediaService interface { Size() int Add(media *Media) error Get(id ContentId) *Media GetAll() []*Media Del(id ContentId) error HideMedia(m *Media, hidden bool) error AdjustMediaDates(anchor *Media, newTime time.Time, extraMedias []*Media) error LoadMediaFromFile(m *Media, file *fileTree.WeblensFileImpl) error RemoveFileFromMedia(media *Media, fileId fileTree.FileId) error Cleanup() error AddFileToMedia(media *Media, file *fileTree.WeblensFileImpl) error GetMediaType(m *Media) MediaType GetMediaTypes() MediaTypeService IsFileDisplayable(file *fileTree.WeblensFileImpl) bool IsCached(m *Media) bool GetProminentColors(media *Media) (prom []string, err error) FetchCacheImg(m *Media, quality MediaQuality, pageNum int) ([]byte, error) StreamVideo(m *Media, u *User, share *FileShare) (*VideoStreamer, error) StreamCacheVideo(m *Media, startByte, endByte int) ([]byte, error) NukeCache() error GetFilteredMedia( requester *User, sort string, sortDirection int, excludeIds []ContentId, raw bool, hidden bool, ) ([]*Media, error) RecursiveGetMedia(folders ...*fileTree.WeblensFileImpl) []*Media SetMediaLiked(mediaId ContentId, liked bool, username Username) error }
type MediaType ¶
type MediaType struct { Mime string `json:"mime"` Name string `json:"FriendlyName"` Extensions []string `json:"FileExtension"` Displayable bool `json:"IsDisplayable"` Raw bool `json:"IsRaw"` Video bool `json:"IsVideo"` ImgRecog bool `json:"SupportsImgRecog"` MultiPage bool `json:"MultiPage"` RawThumbExifKey string `json:"RawThumbExifKey"` } // @name MediaType
func (MediaType) FriendlyName ¶
func (MediaType) GetThumbExifKey ¶
func (MediaType) IsDisplayable ¶
func (MediaType) IsMultiPage ¶
func (MediaType) IsSupported ¶
func (MediaType) SupportsImgRecog ¶
type MediaTypeService ¶
type MediaTypeService interface { GetMaps() (map[string]MediaType, map[string]MediaType) ParseExtension(ext string) MediaType ParseMime(mime string) MediaType Generic() MediaType Size() int }
func NewTypeService ¶
func NewTypeService(marshMap map[string]MediaType) MediaTypeService
type MoveMeta ¶
type MoveMeta struct { FileIds []fileTree.FileId DestinationFolderId fileTree.FileId NewFilename string FileEvent *fileTree.FileEvent Caster FileCaster User *User FileService FileService }
func (MoveMeta) FormatToResult ¶
func (m MoveMeta) FormatToResult() task.TaskResult
func (MoveMeta) MetaString ¶
type RestoreCoreMeta ¶
type RestoreCoreMeta struct { Core *Instance Local *Instance Pack *ServicePack }
func (RestoreCoreMeta) FormatToResult ¶
func (m RestoreCoreMeta) FormatToResult() task.TaskResult
func (RestoreCoreMeta) JobName ¶
func (m RestoreCoreMeta) JobName() string
func (RestoreCoreMeta) MetaString ¶
func (m RestoreCoreMeta) MetaString() string
func (RestoreCoreMeta) Verify ¶
func (m RestoreCoreMeta) Verify() error
type ScanMeta ¶
type ScanMeta struct { File *fileTree.WeblensFileImpl FileBytes []byte PartialMedia *Media FileService FileService MediaService MediaService TaskService TaskDispatcher TaskSubber TaskSubscriber Caster FileCaster }
func (ScanMeta) FormatToResult ¶
func (m ScanMeta) FormatToResult() task.TaskResult
func (ScanMeta) MetaString ¶
MetaString overrides marshal function for scanMetadata
type ServerRole ¶
type ServerRole = string
const ( InitServerRole ServerRole = "init" CoreServerRole ServerRole = "core" BackupServerRole ServerRole = "backup" RestoreServerRole ServerRole = "restore" )
type ServicePack ¶
type ServicePack struct { FileService FileService MediaService MediaService AccessService AccessService UserService UserService InstanceService InstanceService AlbumService AlbumService TaskService task.TaskService ClientService ClientManager Caster Broadcaster Server Server Loaded atomic.Bool StartupChan chan bool Db *mongo.Database // contains filtered or unexported fields }
func (*ServicePack) AddStartupTask ¶
func (pack *ServicePack) AddStartupTask(taskName, description string)
func (*ServicePack) GetStartupTasks ¶
func (pack *ServicePack) GetStartupTasks() []StartupTask
func (*ServicePack) RemoveStartupTask ¶
func (pack *ServicePack) RemoveStartupTask(taskName string)
type ShareService ¶
type ShareService interface {}
type SocketUser ¶
type SocketUser interface {
SocketType() string
}
type TaskDispatcher ¶
type TaskStages ¶
type TaskStages struct {
// contains filtered or unexported fields
}
func NewBackupTaskStages ¶
func NewBackupTaskStages() *TaskStages
func (*TaskStages) FinishStage ¶
func (ts *TaskStages) FinishStage(key string)
func (*TaskStages) MarshalJSON ¶
func (ts *TaskStages) MarshalJSON() ([]byte, error)
func (*TaskStages) StartStage ¶
func (ts *TaskStages) StartStage(key string)
type TaskSubscriber ¶
type UploadFilesMeta ¶
type UploadFilesMeta struct { ChunkStream chan FileChunk RootFolderId fileTree.FileId ChunkSize int64 TotalSize int64 UploadEvent *fileTree.FileEvent FileService FileService MediaService MediaService TaskService task.TaskService TaskSubber TaskSubscriber User *User Caster FileCaster }
func (UploadFilesMeta) FormatToResult ¶
func (m UploadFilesMeta) FormatToResult() task.TaskResult
func (UploadFilesMeta) JobName ¶
func (m UploadFilesMeta) JobName() string
func (UploadFilesMeta) MetaString ¶
func (m UploadFilesMeta) MetaString() string
func (UploadFilesMeta) Verify ¶
func (m UploadFilesMeta) Verify() error
type User ¶
type User struct { Id primitive.ObjectID `bson:"_id"` Username Username `bson:"username"` Password string `bson:"password"` Admin bool `bson:"admin"` Activated bool `bson:"activated"` IsServerOwner bool `bson:"owner"` HomeId fileTree.FileId `bson:"homeId"` TrashId fileTree.FileId `bson:"trashId"` // The id of the server instance that created this user CreatedBy InstanceId `bson:"createdBy"` SystemUser bool // contains filtered or unexported fields }
func (*User) CheckLogin ¶
func (*User) GetUsername ¶
func (*User) IsSystemUser ¶
func (*User) SetHomeFolder ¶
func (u *User) SetHomeFolder(f *fileTree.WeblensFileImpl)
func (*User) SetTrashFolder ¶
func (u *User) SetTrashFolder(f *fileTree.WeblensFileImpl)
func (*User) SocketType ¶
func (*User) UnmarshalJSON ¶
type UserService ¶
type UserService interface { Size() int Get(id Username) *User Add(user *User) error Del(id Username) error GetAll() (iter.Seq[*User], error) CreateOwner(username, password string) (*User, error) GetPublicUser() *User SearchByUsername(searchString string) (iter.Seq[*User], error) SetUserAdmin(*User, bool) error ActivateUser(*User, bool) error GetRootUser() *User UpdateUserHome(u *User) error UpdateUserPassword(username Username, oldPassword, newPassword string, allowEmptyOld bool) error }
type VideoStreamer ¶
type VideoStreamer struct {
// contains filtered or unexported fields
}
func NewVideoStreamer ¶
func NewVideoStreamer(file *fileTree.WeblensFileImpl) *VideoStreamer
func (*VideoStreamer) Encode ¶
func (vs *VideoStreamer) Encode(f *fileTree.WeblensFileImpl) *VideoStreamer
func (*VideoStreamer) Err ¶
func (vs *VideoStreamer) Err() error
func (*VideoStreamer) GetChunk ¶
func (vs *VideoStreamer) GetChunk(chunkName string) (*os.File, error)
func (*VideoStreamer) GetEncodeDir ¶
func (vs *VideoStreamer) GetEncodeDir() string
func (*VideoStreamer) GetListFile ¶
func (vs *VideoStreamer) GetListFile() ([]byte, error)
func (*VideoStreamer) IsTranscoding ¶
func (vs *VideoStreamer) IsTranscoding() bool
type WeblensApiKey ¶
type WeblensApiKey = string
type WsAction ¶
type WsAction string
WsAction is an action sent by the client to the server
const ( // UserSubscribe does not actually get "subscribed" to, it is automatically tracked for every websocket // connection made, and only sends updates to that specific user when needed UserSubscribe WsAction = "userSubscribe" FolderSubscribe WsAction = "folderSubscribe" TaskSubscribe WsAction = "taskSubscribe" TaskTypeSubscribe WsAction = "taskTypeSubscribe" Unsubscribe WsAction = "unsubscribe" ScanDirectory WsAction = "scanDirectory" CancelTask WsAction = "cancelTask" ReportError WsAction = "showWebError" )
type WsClient ¶
func (*WsClient) AddSubscription ¶
func (wsc *WsClient) AddSubscription(sub Subscription)
func (*WsClient) ClientType ¶
func (wsc *WsClient) ClientType() ClientType
func (*WsClient) Disconnect ¶
func (wsc *WsClient) Disconnect()
func (*WsClient) GetClientId ¶
func (*WsClient) GetShortId ¶
func (*WsClient) GetSubscriptions ¶
func (wsc *WsClient) GetSubscriptions() iter.Seq[Subscription]
func (*WsClient) PushFileUpdate ¶
func (wsc *WsClient) PushFileUpdate(updatedFile *fileTree.WeblensFileImpl, media *Media)
func (*WsClient) PushPoolUpdate ¶
func (*WsClient) PushTaskUpdate ¶
func (*WsClient) PushWeblensEvent ¶
func (*WsClient) RemoveSubscription ¶
func (*WsClient) Send ¶
func (wsc *WsClient) Send(msg WsResponseInfo) error
type WsRequestInfo ¶
type WsResponseInfo ¶
type WsResponseInfo struct { EventTag string `json:"eventTag"` SubscribeKey SubId `json:"subscribeKey"` TaskType string `json:"taskType,omitempty"` Content WsC `json:"content"` Error string `json:"error,omitempty"` BroadcastType WsAction `json:"broadcastType,omitempty"` RelaySource InstanceId `json:"relaySource,omitempty"` SentTime int64 `json:"sentTime,omitempty"` }
type ZipMeta ¶
type ZipMeta struct { Files []*fileTree.WeblensFileImpl Requester *User FileService FileService Caster FileCaster }
func (ZipMeta) FormatToResult ¶
func (m ZipMeta) FormatToResult() task.TaskResult
func (ZipMeta) MetaString ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.