-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
153 lines (132 loc) · 3.79 KB
/
types.go
File metadata and controls
153 lines (132 loc) · 3.79 KB
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
package main
import "log/slog"
const (
ExitCmdLineArgsFailure = iota //1
ExitConfigFailure
ExitNoPasswordSet
ExitJetStreamFailure
ExitPostOfficeFailure
ExitBotFailure
ExitGetToken
ExitRefreshToken
ExitWebSocketFailure
)
const ServerArgsPre string = "wss://"
const ServerArgsPost string = "/subscribe?wantedCollections=app.bsky.feed.post"
const ApiUrl string = "https://bsky.social/xrpc"
const CreateSessionEndpoint string = "com.atproto.server.createSession"
const CreatePostEndpoint string = "com.atproto.repo.createRecord"
const RefreshEndpoint string = "com.atproto.server.refreshSession"
const DidLookUpEndpoint string = "https://plc.directory"
const WebsocketTimeout int = 5
const ByteWorker int = 4
const TokenRefreshAttempts = 5
var TokenRefreshTimeoutMs = 5000
const ByteSliceBufferSize = 10
/*Build info*/
var ReleaseVersion string = "Development"
var BuildTime string
/* Global var for logging level & Debug Posts */
/* I don't really like global vars, but it gets written once and is read once */
/* so it should be safe */
var LogLevel slog.Level = slog.LevelInfo
var DebugPosts bool = false
type ClArgs struct {
LogLevel slog.Level
ConfigFilePath string
LogPath string
JsonLog bool
}
type Config struct {
Identifier string
Terms []string
//Add jetstream instance, allowing users to set their preferred instance
//Also add the ability to auto select public instance automatically based on
//latency
JetStreamServer string
autoJetStream bool // CustomJet
password string //unexported
}
func (c *Config) setAutoJetStream() {
c.autoJetStream = true
}
func (c *Config) getAutoJetStream() bool {
return c.autoJetStream
}
type Commit struct {
CID string `json:"cid"`
Collection string `json:"collection"`
Operation string `json:"operation"`
Record Record `json:"record"`
Rev string `json:"rev"`
RKey string `json:"rkey"`
}
type Record struct {
Type string `json:"$type"`
CreatedAt string `json:"createdAt"`
Langs []string `json:"langs"`
Reply Reply `json:"reply"`
Text string `json:"text"`
}
type Reply struct {
Parent Parent `json:"parent"`
Root Parent `json:"root"`
}
type Parent struct {
CID string `json:"cid"`
URI string `json:"uri"`
}
type Message struct {
Commit Commit `json:"commit"`
DID string `json:"did"`
Kind string `json:"kind"`
TimeUs int64 `json:"time_us"`
}
type DIDResponse struct {
DID string `json:"did"`
DIDDoc DIDDoc `json:"didDoc"`
Handle string `json:"handle"`
Email string `json:"email"`
EmailConfirmed bool `json:"emailConfirmed"`
EmailAuthFactor bool `json:"emailAuthFactor"`
AccessJwt string `json:"accessJwt"`
RefreshJwt string `json:"refreshJwt"`
Active bool `json:"active"`
}
type DIDDoc struct {
Context []string `json:"@context"`
ID string `json:"id"`
AlsoKnownAs []string `json:"alsoKnownAs"`
VerificationMethod []struct {
ID string `json:"id"`
Type string `json:"type"`
Controller string `json:"controller"`
PublicKeyMultibase string `json:"publicKeyMultibase"`
} `json:"verificationMethod"`
Service []struct {
ID string `json:"id"`
Type string `json:"type"`
ServiceEndpoint string `json:"serviceEndpoint"`
} `json:"service"`
}
type CreateRecordProps struct {
DIDResponse *DIDResponse
Resource string
URI string
CID string
}
type TokenServer struct {
Request chan bool
Response chan DIDResponse
}
type ChanPkg struct {
ByteSlice chan []byte
ReqDidResp chan bool
Session chan DIDResponse
JetStreamError chan bool
Exit chan int
}
type tokenCreate struct {
Identifier string `json:"identifier"`
Secret string `json:"password"`
}