1
0
mirror of https://github.com/writeas/go-nodeinfo.git synced 2025-07-18 21:08:17 +00:00
go-nodeinfo/service.go

35 lines
651 B
Go

package nodeinfo
const (
profileVer = "2.0"
profile = "http://nodeinfo.diaspora.software/ns/schema/" + profileVer
)
type Service struct {
InfoURL string
Info NodeInfo
resolver Resolver
}
func NewService(cfg Config, r Resolver) *Service {
return &Service{
InfoURL: cfg.BaseURL + cfg.InfoURL,
Info: NodeInfo{
Metadata: cfg.Metadata,
Protocols: cfg.Protocols,
Services: cfg.Services,
Software: cfg.Software,
},
resolver: r,
}
}
func (s Service) BuildInfo() NodeInfo {
ni := s.Info
ni.OpenRegistrations, _ = s.resolver.IsOpenRegistration()
ni.Usage, _ = s.resolver.Usage()
ni.Version = profileVer
return ni
}