Dedicated ChangeLog events for ban/lifecycle/admin changes

This commit is contained in:
Noah Petherbridge 2024-02-25 17:36:01 -08:00
parent 3142e0ce84
commit 2820cf581e
3 changed files with 12 additions and 4 deletions

View File

@ -43,7 +43,7 @@ func Deactivate() http.HandlerFunc {
templates.Redirect(w, "/") templates.Redirect(w, "/")
// Log the change. // Log the change.
models.LogUpdated(currentUser, nil, "users", currentUser.ID, "Deactivated their account.", nil) models.LogEvent(currentUser, nil, models.ChangeLogLifecycle, "users", currentUser.ID, "Deactivated their account.")
return return
} }
@ -83,6 +83,6 @@ func Reactivate() http.HandlerFunc {
templates.Redirect(w, "/") templates.Redirect(w, "/")
// Log the change. // Log the change.
models.LogUpdated(currentUser, nil, "users", currentUser.ID, "Reactivated their account.", nil) models.LogEvent(currentUser, nil, models.ChangeLogLifecycle, "users", currentUser.ID, "Reactivated their account.")
}) })
} }

View File

@ -158,7 +158,7 @@ func UserActions() http.HandlerFunc {
templates.Redirect(w, "/u/"+user.Username) templates.Redirect(w, "/u/"+user.Username)
// Log the change. // Log the change.
models.LogUpdated(user, currentUser, "users", currentUser.ID, fmt.Sprintf("User ban status updated to: %s", status), nil) models.LogEvent(user, currentUser, models.ChangeLogBanned, "users", currentUser.ID, fmt.Sprintf("User ban status updated to: %s", status))
return return
} }
case "promote": case "promote":
@ -177,7 +177,7 @@ func UserActions() http.HandlerFunc {
templates.Redirect(w, "/u/"+user.Username) templates.Redirect(w, "/u/"+user.Username)
// Log the change. // Log the change.
models.LogUpdated(user, currentUser, "users", currentUser.ID, fmt.Sprintf("User admin status updated to: %s", action), nil) models.LogEvent(user, currentUser, models.ChangeLogAdmin, "users", currentUser.ID, fmt.Sprintf("User admin status updated to: %s", action))
return return
} }
case "delete": case "delete":

View File

@ -33,6 +33,11 @@ const (
// Certification photos. // Certification photos.
ChangeLogApproved = "approved" ChangeLogApproved = "approved"
ChangeLogRejected = "rejected" ChangeLogRejected = "rejected"
// Account status updates for easier filtering.
ChangeLogBanned = "banned"
ChangeLogAdmin = "admin" // admin status toggle
ChangeLogLifecycle = "lifecycle" // de/reactivated accounts
) )
var ChangeLogEventTypes = []string{ var ChangeLogEventTypes = []string{
@ -41,6 +46,9 @@ var ChangeLogEventTypes = []string{
ChangeLogDeleted, ChangeLogDeleted,
ChangeLogApproved, ChangeLogApproved,
ChangeLogRejected, ChangeLogRejected,
ChangeLogBanned,
ChangeLogAdmin,
ChangeLogLifecycle,
} }
// PaginateChangeLog lists the change logs. // PaginateChangeLog lists the change logs.