activity: render all activities correctly

the activity type, usernames, time, referrer, and invite code are
displayed correctly for all types of activity.
This commit is contained in:
Harvey Tindall
2023-10-21 12:53:53 +01:00
parent 1032e4e747
commit 44172074b9
6 changed files with 55 additions and 12 deletions

View File

@@ -138,12 +138,15 @@ func (app *appContext) GetActivities(gc *gin.Context) {
Value: act.Value,
Time: act.Time.Unix(),
}
user, status, err := app.jf.UserByID(act.UserID, false)
if status == 200 && err == nil {
if act.Type == ActivityDeletion || act.Type == ActivityCreation {
resp.Activities[i].Username = act.Value
resp.Activities[i].Value = ""
} else if user, status, err := app.jf.UserByID(act.UserID, false); status == 200 && err == nil {
resp.Activities[i].Username = user.Name
}
if (act.SourceType == ActivityUser || act.SourceType == ActivityAdmin) && act.Source != "" {
user, status, err = app.jf.UserByID(act.Source, false)
user, status, err := app.jf.UserByID(act.Source, false)
if status == 200 && err == nil {
resp.Activities[i].SourceUsername = user.Name
}