types.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package dropbox
  2. import (
  3. "time"
  4. "github.com/IceWhaleTech/CasaOS-Common/utils/logger"
  5. "github.com/IceWhaleTech/CasaOS/model"
  6. "go.uber.org/zap"
  7. )
  8. type UserInfo struct {
  9. AccountID string `json:"account_id"`
  10. Name struct {
  11. GivenName string `json:"given_name"`
  12. Surname string `json:"surname"`
  13. FamiliarName string `json:"familiar_name"`
  14. DisplayName string `json:"display_name"`
  15. AbbreviatedName string `json:"abbreviated_name"`
  16. } `json:"name"`
  17. Email string `json:"email"`
  18. EmailVerified bool `json:"email_verified"`
  19. Disabled bool `json:"disabled"`
  20. Country string `json:"country"`
  21. Locale string `json:"locale"`
  22. ReferralLink string `json:"referral_link"`
  23. IsPaired bool `json:"is_paired"`
  24. AccountType struct {
  25. Tag string `json:".tag"`
  26. } `json:"account_type"`
  27. RootInfo struct {
  28. Tag string `json:".tag"`
  29. RootNamespaceID string `json:"root_namespace_id"`
  30. HomeNamespaceID string `json:"home_namespace_id"`
  31. } `json:"root_info"`
  32. }
  33. type TokenError struct {
  34. Error string `json:"error"`
  35. ErrorDescription string `json:"error_description"`
  36. }
  37. type File struct {
  38. Tag string `json:".tag"`
  39. Name string `json:"name"`
  40. PathLower string `json:"path_lower"`
  41. PathDisplay string `json:"path_display"`
  42. ID string `json:"id"`
  43. ClientModified time.Time `json:"client_modified,omitempty"`
  44. ServerModified time.Time `json:"server_modified,omitempty"`
  45. Rev string `json:"rev,omitempty"`
  46. Size int `json:"size,omitempty"`
  47. IsDownloadable bool `json:"is_downloadable,omitempty"`
  48. ContentHash string `json:"content_hash,omitempty"`
  49. }
  50. type Files struct {
  51. Files []File `json:"entries"`
  52. Cursor string `json:"cursor"`
  53. HasMore bool `json:"has_more"`
  54. }
  55. type Error struct {
  56. Error struct {
  57. Errors []struct {
  58. Domain string `json:"domain"`
  59. Reason string `json:"reason"`
  60. Message string `json:"message"`
  61. LocationType string `json:"location_type"`
  62. Location string `json:"location"`
  63. }
  64. Code int `json:"code"`
  65. Message string `json:"message"`
  66. } `json:"error"`
  67. }
  68. func fileToObj(f File) *model.ObjThumb {
  69. logger.Info("dropbox file", zap.Any("file", f))
  70. obj := &model.ObjThumb{
  71. Object: model.Object{
  72. ID: f.ID,
  73. Name: f.Name,
  74. Size: int64(f.Size),
  75. Modified: f.ClientModified,
  76. IsFolder: f.Tag == "folder",
  77. Path: f.PathDisplay,
  78. },
  79. Thumbnail: model.Thumbnail{},
  80. }
  81. return obj
  82. }