60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package webshared
|
|
|
|
import (
|
|
"git.mstar.dev/mstar/goutils/sliceutils"
|
|
|
|
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
|
)
|
|
|
|
type NodeInfoLink struct {
|
|
Rel string
|
|
Href string
|
|
}
|
|
|
|
type NodeInfoOverview struct {
|
|
Links []NodeInfoLink
|
|
}
|
|
|
|
type NodeInfo2Software struct {
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
Homepage *string `json:"homepage,omitempty"`
|
|
Repository *string `json:"repository,omitempty"`
|
|
}
|
|
|
|
type NodeInfo2UsageUsers struct {
|
|
Total uint `json:"total"`
|
|
ActiveHalfYear *uint `json:"active_half_year"`
|
|
ActiveMonth *uint `json:"active_month"`
|
|
}
|
|
|
|
type NodeInfo2Usage struct {
|
|
Users NodeInfo2UsageUsers `json:"users"`
|
|
LocalPosts uint `json:"local_posts"`
|
|
LocalComments uint `json:"local_comments"`
|
|
}
|
|
|
|
type NodeInfo2 struct {
|
|
Version string `json:"version"`
|
|
Software NodeInfo2Software `json:"software"`
|
|
Protocols []string `json:"protocols"`
|
|
Services map[string][]string `json:"services"`
|
|
OpenRegistrations bool `json:"open_registrations"`
|
|
Usage NodeInfo2Usage `json:"usage"`
|
|
Metadata map[string]any `json:"metadata"`
|
|
}
|
|
|
|
func MapNodeServerTypeToModelType(nodeType string) models.ServerSoftwareType {
|
|
if sliceutils.Contains([]string{"mastodon"}, nodeType) {
|
|
return models.ServerSoftwareMastodon
|
|
} else if sliceutils.Contains([]string{"sharkey", "misskey", "iceshrimp", "firefish"}, nodeType) {
|
|
return models.ServerSoftwareMisskey
|
|
} else if sliceutils.Contains([]string{"linstrom"}, nodeType) {
|
|
return models.ServerSoftwareLinstrom
|
|
} else if sliceutils.Contains([]string{"akkoma"}, nodeType) {
|
|
return models.ServerSoftwarePlemora
|
|
} else if sliceutils.Contains([]string{"wafrn"}, nodeType) {
|
|
return models.ServerSoftwareWafrn
|
|
}
|
|
return models.ServerSoftwareUnknown
|
|
}
|