activity.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package api
  2. import "github.com/usememos/memos/server/profile"
  3. // ActivityType is the type for an activity.
  4. type ActivityType string
  5. const (
  6. // User related.
  7. // ActivityUserCreate is the type for creating users.
  8. ActivityUserCreate ActivityType = "user.create"
  9. // ActivityUserUpdate is the type for updating users.
  10. ActivityUserUpdate ActivityType = "user.update"
  11. // ActivityUserDelete is the type for deleting users.
  12. ActivityUserDelete ActivityType = "user.delete"
  13. // ActivityUserAuthSignIn is the type for user signin.
  14. ActivityUserAuthSignIn ActivityType = "user.auth.signin"
  15. // ActivityUserAuthSignUp is the type for user signup.
  16. ActivityUserAuthSignUp ActivityType = "user.auth.signup"
  17. // ActivityUserSettingUpdate is the type for updating user settings.
  18. ActivityUserSettingUpdate ActivityType = "user.setting.update"
  19. // Memo related.
  20. // ActivityMemoCreate is the type for creating memos.
  21. ActivityMemoCreate ActivityType = "memo.create"
  22. // ActivityMemoUpdate is the type for updating memos.
  23. ActivityMemoUpdate ActivityType = "memo.update"
  24. // ActivityMemoDelete is the type for deleting memos.
  25. ActivityMemoDelete ActivityType = "memo.delete"
  26. // Shortcut related.
  27. // ActivityShortcutCreate is the type for creating shortcuts.
  28. ActivityShortcutCreate ActivityType = "shortcut.create"
  29. // ActivityShortcutUpdate is the type for updating shortcuts.
  30. ActivityShortcutUpdate ActivityType = "shortcut.update"
  31. // ActivityShortcutDelete is the type for deleting shortcuts.
  32. ActivityShortcutDelete ActivityType = "shortcut.delete"
  33. // Resource related.
  34. // ActivityResourceCreate is the type for creating resources.
  35. ActivityResourceCreate ActivityType = "resource.create"
  36. // ActivityResourceDelete is the type for deleting resources.
  37. ActivityResourceDelete ActivityType = "resource.delete"
  38. // Tag related.
  39. // ActivityTagCreate is the type for creating tags.
  40. ActivityTagCreate ActivityType = "tag.create"
  41. // ActivityTagDelete is the type for deleting tags.
  42. ActivityTagDelete ActivityType = "tag.delete"
  43. // Server related.
  44. // ActivityServerStart is the type for starting server.
  45. ActivityServerStart ActivityType = "server.start"
  46. )
  47. // ActivityLevel is the level of activities.
  48. type ActivityLevel string
  49. const (
  50. // ActivityInfo is the INFO level of activities.
  51. ActivityInfo ActivityLevel = "INFO"
  52. // ActivityWarn is the WARN level of activities.
  53. ActivityWarn ActivityLevel = "WARN"
  54. // ActivityError is the ERROR level of activities.
  55. ActivityError ActivityLevel = "ERROR"
  56. )
  57. type ActivityUserCreatePayload struct {
  58. UserID int `json:"userId"`
  59. Username string `json:"username"`
  60. Role Role `json:"role"`
  61. }
  62. type ActivityUserAuthSignInPayload struct {
  63. UserID int `json:"userId"`
  64. IP string `json:"ip"`
  65. }
  66. type ActivityUserAuthSignUpPayload struct {
  67. Username string `json:"username"`
  68. IP string `json:"ip"`
  69. }
  70. type ActivityMemoCreatePayload struct {
  71. Content string `json:"content"`
  72. Visibility string `json:"visibility"`
  73. }
  74. type ActivityShortcutCreatePayload struct {
  75. Title string `json:"title"`
  76. Payload string `json:"payload"`
  77. }
  78. type ActivityResourceCreatePayload struct {
  79. Filename string `json:"filename"`
  80. Type string `json:"type"`
  81. Size int64 `json:"size"`
  82. }
  83. type ActivityTagCreatePayload struct {
  84. TagName string `json:"tagName"`
  85. }
  86. type ActivityServerStartPayload struct {
  87. ServerID string `json:"serverId"`
  88. Profile *profile.Profile `json:"profile"`
  89. }
  90. type Activity struct {
  91. ID int `json:"id"`
  92. // Standard fields
  93. CreatorID int `json:"creatorId"`
  94. CreatedTs int64 `json:"createdTs"`
  95. // Domain specific fields
  96. Type ActivityType `json:"type"`
  97. Level ActivityLevel `json:"level"`
  98. Payload string `json:"payload"`
  99. }
  100. // ActivityCreate is the API message for creating an activity.
  101. type ActivityCreate struct {
  102. // Standard fields
  103. CreatorID int
  104. // Domain specific fields
  105. Type ActivityType `json:"type"`
  106. Level ActivityLevel
  107. Payload string `json:"payload"`
  108. }