-
Notifications
You must be signed in to change notification settings - Fork 6
/
models.go
executable file
·121 lines (108 loc) · 4.27 KB
/
models.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
package feed
import (
"html/template"
"sync"
"time"
"github.com/cihub/seelog"
cache "github.com/robfig/go-cache"
"github.com/schollz/kiki/src/database"
"github.com/schollz/kiki/src/keypair"
"github.com/schollz/kiki/src/letter"
"github.com/schollz/kiki/src/logging"
)
type Response struct {
PersonalSignature string `json:"personal_signature"`
PersonalPublicKey string `json:"personal_key"`
IDs []string `json:"ids"`
Envelope letter.Envelope `json:"envelope"`
Error string `json:"error"`
Message string `json:"message"`
Status string `json:"status"`
}
// Feed stores your basic data
type Feed struct {
RegionKey keypair.KeyPair `json:"region_key"`
Settings Settings `json:"settings"`
PersonalKey keypair.KeyPair `json:"personal_key"`
locationToKiki string
locationToKikiDB string
locationToKikiSearch string
locationToKikiSettings string
db database.DatabaseAPI
log seelog.LoggerInterface
logger logging.SeelogWrapper
caching *cache.Cache
servers connections
}
type connections struct {
connected map[string]User
blockedUsers map[string]struct{}
syncingCount int
updating bool
sync.RWMutex
}
type Settings struct {
StoragePerPublicPerson int64 `json:"storage_per_person"` // maximum size in bytes to store of public messages. Once exceeded, old messages are purged
StoragePerFriend int64 `json:"storage_per_friend"` // maximum size in bytes to store of friend messages. Once exceeded, old messages are purged
FriendsOfFriends bool `json:"friends_of_friends"` // whether you want to share your friends friend keys with new friends, effectively making a new friend friends with all your friends. This also means that when you make a new friend, that friends key is emitted to all your current friends. (default: true)
BlockPublicPhotos bool `json:"block_public_photos"` // if true, block the transfer of any public photos to your computer
AvailableServers []string `json:"available_servers"`
}
// GenerateSettings create new instance of Something
func GenerateSettings() Settings {
return Settings{
StoragePerPublicPerson: 5000000 / 4, // 5 MB
StoragePerFriend: 50000000 / 4, // 50 MB
FriendsOfFriends: true,
BlockPublicPhotos: true,
AvailableServers: []string{},
}
}
type Post struct {
Post BasicPost `json:"post"`
Comments []BasicPost `json:"comments"`
}
type BasicPost struct {
Depth int `json:"depth"`
ID string `json:"id"`
FirstID string `json:"first_id"`
Recipients string `json:"recipients"`
ReplyTo string `json:"reply_to"`
Content template.HTML `json:"content"`
Date time.Time `json:"date"`
TimeAgo string `json:"time_ago"`
User User `json:"user"`
Likes int64 `json:"likes"`
Comments []BasicPost `json:"comments"`
}
// // TESTING
// type ApiBasicPost struct {
// // Depth int `json:"depth"`
// ID string `json:"id"`
// Recipients string `json:"recipients"`
// ReplyTo string `json:"reply_to"`
// Content template.HTML `json:"content"`
// Date time.Time `json:"date"`
// TimeAgo string `json:"time_ago"`
// OwnerId string `json:"owner_id"`
// Likes int64 `json:"likes"`
// NumComments int64 `json:"num_comments"`
// }
type User struct {
Name string `json:"name"`
Profile template.HTML `json:"profile"`
ProfileContent template.HTMLAttr `json:"profile_attr"`
PublicKey string `json:"public_key"`
PublicHash string `json:"public_hash"`
Image string `json:"image"`
Followers []string `json:"followers"`
Following []string `json:"following"`
Friends []string `json:"friends"`
Blocked []string `json:"blocked"`
Server string `json:"server"`
}
type UserFriends struct {
Friends []User `json:"user_friends"`
Followers []User `json:"user_followers"`
Following []User `json:"user_following"`
}