forked from writeas/go-nodeinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodeinfo.go
98 lines (87 loc) · 3.01 KB
/
nodeinfo.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
package nodeinfo
type (
NodeProtocol string
NodeService string
)
const (
// Protocols that can be supported by this node.
ProtocolActivityPub NodeProtocol = "activitypub"
ProtocolBuddyCloud = "buddycloud"
ProtocolDFRN = "dfrn"
ProtocolDisaspora = "diaspora"
ProtocolLibertree = "libertree"
ProtocolOStatus = "ostatus"
ProtocolPumpIO = "pumpio"
ProtocolTent = "tent"
ProtocolXMPP = "xmpp"
ProtocolZot = "zot"
// Services that can be supported (inbound or outbound) by this node's API.
ServiceAtom NodeService = "atom1.0"
ServiceGNUSocial = "gnusocial"
ServiceIMAP = "imap"
ServicePnut = "pnut"
ServicePOP3 = "pop3"
ServicePumpIO = "pumpio"
ServiceRSS = "rss2.0"
ServiceTwitter = "twitter"
ServiceTumblr = "tumblr"
)
type Config struct {
BaseURL string
InfoURL string
Metadata Metadata
Protocols []NodeProtocol
Services Services
Software SoftwareInfo
}
type (
// NodeInfo includes all required node info.
NodeInfo struct {
Metadata Metadata `json:"metadata"`
OpenRegistrations bool `json:"openRegistrations"`
Protocols []NodeProtocol `json:"protocols"`
Services Services `json:"services"`
Software SoftwareInfo `json:"software"`
Usage Usage `json:"usage"`
Version string `json:"version"`
}
// Metadata for nodeinfo. Properties are based on what Pleroma uses.
//
// From the spec: Free form key value pairs for software specific values.
// Clients should not rely on any specific key present.
Metadata struct {
NodeName string `json:"nodeName,omitempty"`
NodeDescription string `json:"nodeDescription,omitempty"`
Private bool `json:"private,omitempty"`
Software SoftwareMeta `json:"software,omitempty"`
MaxBlogs int `json:"maxBlogs,omitempty"`
PublicReader bool `json:"publicReader"`
Invites bool `json:"invites"`
}
Services struct {
Inbound []NodeService `json:"inbound"`
Outbound []NodeService `json:"outbound"`
}
SoftwareInfo struct {
// Name (canonical) of this server software.
Name string `json:"name"`
// Version of this server software.
Version string `json:"version"`
}
SoftwareMeta struct {
HomePage string `json:"homepage"`
GitHub string `json:"github"`
Follow string `json:"follow"`
}
// Usage is usage statistics for this server.
Usage struct {
Users UsageUsers `json:"users"`
LocalPosts int `json:"localPosts,omitempty"`
LocalComments int `json:"localComments,omitempty"`
}
UsageUsers struct {
Total int `json:"total,omitempty"`
ActiveHalfYear int `json:"activeHalfyear,omitempty"`
ActiveMonth int `json:"activeMonth,omitempty"`
}
)