NodeInfo server implemented in Go.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

96 lignes
2.9 KiB

  1. package nodeinfo
  2. type (
  3. NodeProtocol string
  4. NodeService string
  5. )
  6. const (
  7. // Protocols that can be supported by this node.
  8. ProtocolActivityPub NodeProtocol = "activitypub"
  9. ProtocolBuddyCloud = "buddycloud"
  10. ProtocolDFRN = "dfrn"
  11. ProtocolDisaspora = "diaspora"
  12. ProtocolLibertree = "libertree"
  13. ProtocolOStatus = "ostatus"
  14. ProtocolPumpIO = "pumpio"
  15. ProtocolTent = "tent"
  16. ProtocolXMPP = "xmpp"
  17. ProtocolZot = "zot"
  18. // Services that can be supported (inbound or outbound) by this node's API.
  19. ServiceAtom NodeService = "atom1.0"
  20. ServiceGNUSocial = "gnusocial"
  21. ServiceIMAP = "imap"
  22. ServicePnut = "pnut"
  23. ServicePOP3 = "pop3"
  24. ServicePumpIO = "pumpio"
  25. ServiceRSS = "rss2.0"
  26. ServiceTwitter = "twitter"
  27. ServiceTumblr = "tumblr"
  28. )
  29. type Config struct {
  30. BaseURL string
  31. InfoURL string
  32. Metadata Metadata
  33. Protocols []NodeProtocol
  34. Services Services
  35. Software SoftwareInfo
  36. }
  37. type (
  38. // NodeInfo includes all required node info.
  39. NodeInfo struct {
  40. Metadata Metadata `json:"metadata"`
  41. OpenRegistrations bool `json:"openRegistrations"`
  42. Protocols []NodeProtocol `json:"protocols"`
  43. Services Services `json:"services"`
  44. Software SoftwareInfo `json:"software"`
  45. Usage Usage `json:"usage"`
  46. Version string `json:"version"`
  47. }
  48. // Metadata for nodeinfo. Properties are based on what Pleroma uses.
  49. //
  50. // From the spec: Free form key value pairs for software specific values.
  51. // Clients should not rely on any specific key present.
  52. Metadata struct {
  53. NodeName string `json:"nodeName,omitempty"`
  54. NodeDescription string `json:"nodeDescription,omitempty"`
  55. Private bool `json:"private,omitempty"`
  56. Software SoftwareMeta `json:"software,omitempty"`
  57. }
  58. Services struct {
  59. Inbound []NodeService `json:"inbound"`
  60. Outbound []NodeService `json:"outbound"`
  61. }
  62. SoftwareInfo struct {
  63. // Name (canonical) of this server software.
  64. Name string `json:"name"`
  65. // Version of this server software.
  66. Version string `json:"version"`
  67. }
  68. SoftwareMeta struct {
  69. HomePage string `json:"homepage"`
  70. GitHub string `json:"github"`
  71. Follow string `json:"follow"`
  72. }
  73. // Usage is usage statistics for this server.
  74. Usage struct {
  75. Users UsageUsers `json:"users"`
  76. LocalPosts int `json:"localPosts,omitempty"`
  77. LocalComments int `json:"localComments,omitempty"`
  78. }
  79. UsageUsers struct {
  80. Total int `json:"total,omitempty"`
  81. ActiveHalfYear int `json:"activeHalfyear,omitempty"`
  82. ActiveMonth int `json:"activeMonth,omitempty"`
  83. }
  84. )