Neeraj Gupta 1 year ago
parent
commit
2b2c3f47d8
7 changed files with 44 additions and 45 deletions
  1. 3 3
      pkg/collections.go
  2. 3 3
      pkg/download.go
  3. 1 1
      pkg/log/debug_print.go
  4. 5 5
      pkg/mappers.go
  5. 0 14
      pkg/model/album.go
  6. 0 19
      pkg/model/photo_file.go
  7. 32 0
      pkg/model/remote.go

+ 3 - 3
pkg/collections.go

@@ -110,14 +110,14 @@ func (c *ClICtrl) fetchRemoteFiles(ctx context.Context) error {
 	return nil
 }
 
-func (c *ClICtrl) getRemoteAlbums(ctx context.Context) ([]model.Album, error) {
-	albums := make([]model.Album, 0)
+func (c *ClICtrl) getRemoteAlbums(ctx context.Context) ([]model.RemoteAlbum, error) {
+	albums := make([]model.RemoteAlbum, 0)
 	albumBytes, err := c.GetAllValues(ctx, model.RemoteAlbums)
 	if err != nil {
 		return nil, err
 	}
 	for _, albumJson := range albumBytes {
-		album := model.Album{}
+		album := model.RemoteAlbum{}
 		err = json.Unmarshal(albumJson, &album)
 		if err != nil {
 			return nil, err

+ 3 - 3
pkg/download.go

@@ -29,14 +29,14 @@ func (c *ClICtrl) initiateDownload(ctx context.Context) error {
 	return nil
 }
 
-func (c *ClICtrl) getRemoteFiles(ctx context.Context) ([]model.PhotoFile, error) {
-	files := make([]model.PhotoFile, 0)
+func (c *ClICtrl) getRemoteFiles(ctx context.Context) ([]model.RemoteFile, error) {
+	files := make([]model.RemoteFile, 0)
 	fileBytes, err := c.GetAllValues(ctx, model.RemoteFiles)
 	if err != nil {
 		return nil, err
 	}
 	for _, fileJson := range fileBytes {
-		file := model.PhotoFile{}
+		file := model.RemoteFile{}
 		err = json.Unmarshal(fileJson, &file)
 		if err != nil {
 			return nil, err

+ 1 - 1
pkg/log/debug_print.go

@@ -7,7 +7,7 @@ import (
 
 // This file contains functions that are used to print debug information to the console.
 
-func PrintAlbum(a *model.Album) {
+func PrintAlbum(a *model.RemoteAlbum) {
 	fmt.Printf("=======\n")
 	fmt.Printf("ID: %d\n", a.ID)
 	fmt.Printf("OwnerID: %d\n", a.OwnerID)

+ 5 - 5
pkg/mappers.go

@@ -11,8 +11,8 @@ import (
 	"log"
 )
 
-func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Collection) (*model.Album, error) {
-	var album model.Album
+func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Collection) (*model.RemoteAlbum, error) {
+	var album model.RemoteAlbum
 	userID := ctx.Value("user_id").(int64)
 	album.OwnerID = collection.Owner.ID
 	album.ID = collection.ID
@@ -69,7 +69,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
 	return &album, nil
 }
 
-func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.Album, file api.File) (*model.PhotoFile, error) {
+func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteAlbum, file api.File) (*model.RemoteFile, error) {
 	if file.IsDeleted {
 		return nil, errors.New("file is deleted")
 	}
@@ -81,14 +81,14 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.Album,
 	if err != nil {
 		return nil, err
 	}
-	var photoFile model.PhotoFile
+	var photoFile model.RemoteFile
 	photoFile.ID = file.ID
 	photoFile.Key = *model.MakeEncString(fileKey, c.CliKey)
 	photoFile.FileNonce = file.File.DecryptionHeader
 	photoFile.ThumbnailNonce = file.Thumbnail.DecryptionHeader
 	photoFile.OwnerID = file.OwnerID
 	if file.Info != nil {
-		photoFile.Info = model.PhotoInfo{
+		photoFile.Info = model.Info{
 			FileSize:      file.Info.FileSize,
 			ThumbnailSize: file.Info.ThumbnailSize,
 		}

+ 0 - 14
pkg/model/album.go

@@ -1,14 +0,0 @@
-package model
-
-type Album struct {
-	ID            int64                  `json:"id"`
-	OwnerID       int64                  `json:"ownerID"`
-	IsShared      bool                   `json:"isShared"`
-	IsDeleted     bool                   `json:"isDeleted"`
-	AlbumName     string                 `json:"albumName"`
-	AlbumKey      EncString              `json:"albumKey"`
-	PublicMeta    map[string]interface{} `json:"publicMeta"`
-	PrivateMeta   map[string]interface{} `json:"privateMeta"`
-	SharedMeta    map[string]interface{} `json:"sharedMeta"`
-	LastUpdatedAt int64                  `json:"lastUpdatedAt"`
-}

+ 0 - 19
pkg/model/photo_file.go

@@ -1,19 +0,0 @@
-package model
-
-type PhotoFile struct {
-	ID              int64                  `json:"id"`
-	OwnerID         int64                  `json:"ownerID"`
-	Key             EncString              `json:"key"`
-	LastUpdateTime  int64                  `json:"lastUpdateTime"`
-	FileNonce       string                 `json:"fileNonce"`
-	ThumbnailNonce  string                 `json:"thumbnailNonce"`
-	Metadata        map[string]interface{} `json:"metadata"`
-	PrivateMetadata map[string]interface{} `json:"privateMetadata"`
-	PublicMetadata  map[string]interface{} `json:"publicMetadata"`
-	Info            PhotoInfo              `json:"info"`
-}
-
-type PhotoInfo struct {
-	FileSize      int64 `json:"fileSize,omitempty"`
-	ThumbnailSize int64 `json:"thumbSize,omitempty"`
-}

+ 32 - 0
pkg/model/remote.go

@@ -0,0 +1,32 @@
+package model
+
+type RemoteFile struct {
+	ID              int64                  `json:"id"`
+	OwnerID         int64                  `json:"ownerID"`
+	Key             EncString              `json:"key"`
+	LastUpdateTime  int64                  `json:"lastUpdateTime"`
+	FileNonce       string                 `json:"fileNonce"`
+	ThumbnailNonce  string                 `json:"thumbnailNonce"`
+	Metadata        map[string]interface{} `json:"metadata"`
+	PrivateMetadata map[string]interface{} `json:"privateMetadata"`
+	PublicMetadata  map[string]interface{} `json:"publicMetadata"`
+	Info            Info                   `json:"info"`
+}
+
+type Info struct {
+	FileSize      int64 `json:"fileSize,omitempty"`
+	ThumbnailSize int64 `json:"thumbSize,omitempty"`
+}
+
+type RemoteAlbum struct {
+	ID            int64                  `json:"id"`
+	OwnerID       int64                  `json:"ownerID"`
+	IsShared      bool                   `json:"isShared"`
+	IsDeleted     bool                   `json:"isDeleted"`
+	AlbumName     string                 `json:"albumName"`
+	AlbumKey      EncString              `json:"albumKey"`
+	PublicMeta    map[string]interface{} `json:"publicMeta"`
+	PrivateMeta   map[string]interface{} `json:"privateMeta"`
+	SharedMeta    map[string]interface{} `json:"sharedMeta"`
+	LastUpdatedAt int64                  `json:"lastUpdatedAt"`
+}