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.

82 lignes
2.4 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. ServiceTwitter NodeService = "twitter"
  20. ServiceTumblr = "tumblr"
  21. )
  22. type Config struct {
  23. BaseURL string
  24. InfoURL string
  25. Metadata Metadata
  26. Protocols []NodeProtocol
  27. Services Services
  28. Software SoftwareInfo
  29. }
  30. type (
  31. // NodeInfo includes all required node info.
  32. NodeInfo struct {
  33. Metadata Metadata `json:"metadata"`
  34. OpenRegistrations bool `json:"openRegistrations"`
  35. Protocols []NodeProtocol `json:"protocols"`
  36. Services Services `json:"services"`
  37. Software SoftwareInfo `json:"software"`
  38. Usage Usage `json:"usage"`
  39. Version string `json:"version"`
  40. }
  41. // Metadata for nodeinfo. Properties are based on what Pleroma uses.
  42. //
  43. // From the spec: Free form key value pairs for software specific values.
  44. // Clients should not rely on any specific key present.
  45. Metadata struct {
  46. NodeName string `json:"nodeName,omitempty"`
  47. NodeDescription string `json:"nodeDescription,omitempty"`
  48. Private bool `json:"private,omitempty"`
  49. }
  50. Services struct {
  51. Inbound []NodeService `json:"inbound"`
  52. Outbound []NodeService `json:"outbound"`
  53. }
  54. SoftwareInfo struct {
  55. // Name (canonical) of this server software.
  56. Name string `json:"name"`
  57. // Version of this server software.
  58. Version string `json:"version"`
  59. }
  60. // Usage is usage statistics for this server.
  61. Usage struct {
  62. Users UsageUsers `json:"users"`
  63. LocalPosts int `json:"localPosts,omitempty"`
  64. LocalComments int `json:"localComments,omitempty"`
  65. }
  66. UsageUsers struct {
  67. Total int `json:"total,omitempty"`
  68. ActiveHalfYear int `json:"activeHalfyear,omitempty"`
  69. ActiveMonth int `json:"activeMonth,omitempty"`
  70. }
  71. )