-
Notifications
You must be signed in to change notification settings - Fork 43
/
domain.go
197 lines (166 loc) · 4.01 KB
/
domain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package domain
import "fmt"
type AppConfig struct {
Port int
AppPath string
TextileHubTarget string
TextileThreadsTarget string
}
type DirEntry struct {
Path string
IsDir bool
Name string
SizeInBytes string
Created string
Updated string
FileExtension string
Members []Member
}
type ThreadInfo struct {
Addresses []string
Key string
}
type FileInfo struct {
DirEntry
IpfsHash string
BackedUp bool
LocallyAvailable bool
BackupInProgress bool
RestoreInProgress bool
}
type OpenFileInfo struct {
Location string
}
type KeyPair struct {
PublicKey string
PrivateKey string
}
type AddItemResult struct {
SourcePath string
BucketPath string
Bytes int64
Error error
}
type AddItemsResponse struct {
TotalFiles int64
TotalBytes int64
Error error
}
type Member struct {
Address string `json:"address"`
PublicKey string `json:"publicKey"`
}
type AddWatchFile struct {
DbId string `json:"dbId"`
LocalPath string `json:"local_path"`
BucketPath string `json:"bucket_path"`
BucketKey string `json:"bucket_key"`
BucketSlug string `json:"bucket_slug"`
IsRemote bool `json:"isRemote"`
Cid string `json:"cid"`
}
type Identity struct {
Address string `json:"address"`
PublicKey string `json:"publicKey"`
Username string `json:"username"`
}
type APIError struct {
Message string `json:"message"`
}
type FileSharingInfo struct {
Bucket string
SharedFileCid string
SharedFileKey string
SpaceDownloadLink string
}
type NotificationTypes int
const (
UNKNOWN NotificationTypes = iota
INVITATION
USAGEALERT
INVITATION_REPLY
)
type FullPath struct {
DbId string `json:"dbId"`
BucketKey string `json:"bucketKey"`
Bucket string `json:"bucket"`
Path string `json:"path"`
}
type InvitationStatus int
const (
PENDING InvitationStatus = 0
ACCEPTED InvitationStatus = 1
REJECTED InvitationStatus = 2
)
type Invitation struct {
InviterPublicKey string `json:"inviterPublicKey"`
InviteePublicKey string `json:"inviteePublicKey"`
InvitationID string `json:"invitationID"`
Status InvitationStatus `json:"status"`
ItemPaths []FullPath `json:"itemPaths"`
Keys [][]byte `json:"keys"`
}
type InvitationReply struct {
InvitationID string `json:"invitationID"`
}
type UsageAlert struct {
Used int64 `json:"used"`
Limit int64 `json:"limit"`
Message string `json:"message"`
}
type MessageBody struct {
Type NotificationTypes `json:"type"`
Body []byte `json:"body"`
}
type Notification struct {
ID string `json:"id"`
Subject string `json:"subject"`
Body string `json:"body"`
NotificationType NotificationTypes `json:"notificationType"`
CreatedAt int64 `json:"createdAt"`
ReadAt int64 `json:"readAt"`
// QUESTION: is there a way to enforce that only one of the below is present
InvitationValue Invitation `json:"invitationValue"`
UsageAlertValue UsageAlert `json:"usageAlertValue"`
InvitationAcceptValue InvitationReply `json:"invitationAcceptValue"`
RelatedObject interface{} `json:"relatedObject"`
}
type APISessionTokens struct {
HubToken string
ServicesToken string
}
type MirrorFile struct {
Path string
BucketSlug string
Backup bool
Shared bool
BackupInProgress bool
RestoreInProgress bool
}
type SharedDirEntry struct {
DbID string
Bucket string
IsPublicLink bool
FileInfo
Members []Member // XXX: it is duplicated from FileInfo
}
type SearchFileEntry struct {
FileInfo
Bucket string
DbID string
}
type KeyBackupType int
const (
PASSWORD KeyBackupType = 0
ETH KeyBackupType = 1
)
func (b KeyBackupType) String() string {
switch b {
case 0:
return "password"
case 1:
return "eth"
default:
return fmt.Sprintf("%d", int(b))
}
}