activity: more presentable cards, fixes

fixed some missing data (being stored and being shown), improved layout,
also usernames are now injected by the route.
This commit is contained in:
Harvey Tindall
2023-10-20 22:16:40 +01:00
parent a73dfddd3f
commit 1032e4e747
9 changed files with 113 additions and 43 deletions

View File

@@ -89,7 +89,7 @@ func activitySourceToString(v ActivitySource) string {
// @Produce json
// @Param GetActivitiesDTO body GetActivitiesDTO true "search parameters"
// @Success 200 {object} GetActivitiesRespDTO
// @Router /activity [get]
// @Router /activity [post]
// @Security Bearer
// @tags Activity
func (app *appContext) GetActivities(gc *gin.Context) {
@@ -138,6 +138,16 @@ 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 {
resp.Activities[i].Username = user.Name
}
if (act.SourceType == ActivityUser || act.SourceType == ActivityAdmin) && act.Source != "" {
user, status, err = app.jf.UserByID(act.Source, false)
if status == 200 && err == nil {
resp.Activities[i].SourceUsername = user.Name
}
}
}
gc.JSON(200, resp)