diff --git a/api-users.go b/api-users.go
index 570af70..afab1cb 100644
--- a/api-users.go
+++ b/api-users.go
@@ -1420,7 +1420,30 @@ func (app *appContext) ApplySettings(gc *gin.Context) {
gc.JSON(code, errors)
}
-// @Summary Get the latest Jellyfin/Emby activities related to the given user ID. Returns as many as the server has recorded.
+// @Summary Gets the number of Jellyfin/Emby activities stored by jfa-go related to the given user ID. As the total collected by jfa-go is limited, this may not include all those held by Jellyfin.
+// @Produce json
+// @Success 200 {object} PageCountDTO
+// @Failure 400 {object} boolResponse
+// @Param id path string true "id of user to fetch activities of."
+// @Router /users/{id}/activities/jellyfin/count [get]
+// @Security Bearer
+// @tags Users
+func (app *appContext) CountJFActivitesForUser(gc *gin.Context) {
+ userID := gc.Param("id")
+ if userID == "" {
+ respondBool(400, false, gc)
+ return
+ }
+ activities, err := app.jf.activity.ByUserID(userID)
+ if err != nil {
+ app.err.Printf(lm.FailedGetJFActivities, err)
+ respondBool(400, false, gc)
+ return
+ }
+ gc.JSON(200, PageCountDTO{Count: uint64(len(activities))})
+}
+
+// @Summary Get the latest Jellyfin/Emby activities related to the given user ID. Returns as many as the server has recorded. As the total collected by jfa-go is limited, this may not include all those held by Jellyfin.
// @Produce json
// @Success 200 {object} ActivityLogEntriesDTO
// @Failure 400 {object} boolResponse
@@ -1429,12 +1452,12 @@ func (app *appContext) ApplySettings(gc *gin.Context) {
// @Security Bearer
// @tags Users
func (app *appContext) GetJFActivitesForUser(gc *gin.Context) {
- userId := gc.Param("id")
- if userId == "" {
+ userID := gc.Param("id")
+ if userID == "" {
respondBool(400, false, gc)
return
}
- activities, err := app.jf.activity.ByUserID(userId)
+ activities, err := app.jf.activity.ByUserID(userID)
if err != nil {
app.err.Printf(lm.FailedGetJFActivities, err)
respondBool(400, false, gc)
@@ -1450,3 +1473,46 @@ func (app *appContext) GetJFActivitesForUser(gc *gin.Context) {
app.debug.Printf(lm.GotNEntries, len(activities))
gc.JSON(200, out)
}
+
+// @Summary Get the latest Jellyfin/Emby activities related to the given user ID, paginated. As the total collected by jfa-go is limited, this may not include all those held by Jellyfin.
+// @Produce json
+// @Param PaginatedReqDTO body PaginatedReqDTO true "pagination parameters"
+// @Success 200 {object} PaginatedActivityLogEntriesDTO
+// @Failure 400 {object} boolResponse
+// @Param id path string true "id of user to fetch activities of."
+// @Router /users/{id}/activities/jellyfin [post]
+// @Security Bearer
+// @tags Users
+func (app *appContext) GetPaginatedJFActivitesForUser(gc *gin.Context) {
+ var req PaginatedReqDTO
+ gc.BindJSON(&req)
+ userID := gc.Param("id")
+ if userID == "" {
+ respondBool(400, false, gc)
+ return
+ }
+ activities, err := app.jf.activity.ByUserID(userID)
+ if err != nil {
+ app.err.Printf(lm.FailedGetJFActivities, err)
+ respondBool(400, false, gc)
+ return
+ }
+ out := PaginatedActivityLogEntriesDTO{}
+ startIndex := req.Page * req.Limit
+ if startIndex >= len(activities) {
+ out.LastPage = true
+ gc.JSON(200, out)
+ return
+ }
+ endIndex := min(startIndex+req.Limit, len(activities))
+ activities = activities[startIndex:endIndex]
+
+ out.Entries = make([]ActivityLogEntryDTO, len(activities))
+ out.LastPage = len(activities) != req.Limit
+ for i := range activities {
+ out.Entries[i].ActivityLogEntry = activities[i]
+ out.Entries[i].Date = activities[i].Date.Unix()
+ }
+ app.debug.Printf(lm.GotNEntries, len(activities))
+ gc.JSON(200, out)
+}
diff --git a/go.mod b/go.mod
index 9049f5e..6e98864 100644
--- a/go.mod
+++ b/go.mod
@@ -42,7 +42,7 @@ require (
github.com/hrfee/jfa-go/logger v0.0.0-20251123165523-7c9f91711460
github.com/hrfee/jfa-go/logmessages v0.0.0-20251123165523-7c9f91711460
github.com/hrfee/jfa-go/ombi v0.0.0-20251123165523-7c9f91711460
- github.com/hrfee/mediabrowser v0.3.35
+ github.com/hrfee/mediabrowser v0.3.36
github.com/hrfee/simple-template v1.1.0
github.com/itchyny/timefmt-go v0.1.7
github.com/lithammer/shortuuid/v3 v3.0.7
diff --git a/go.sum b/go.sum
index e8696d1..5ce20a4 100644
--- a/go.sum
+++ b/go.sum
@@ -200,6 +200,8 @@ github.com/hrfee/mediabrowser v0.3.34 h1:AKnd1V9wt+KWZmHDjj1GMkCgcgcpBKxPw5iUcYg
github.com/hrfee/mediabrowser v0.3.34/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
github.com/hrfee/mediabrowser v0.3.35 h1:xEq4cL96Di0G+S3ONBH1HHeQJU6IfUMZiaeGeuJSFS8=
github.com/hrfee/mediabrowser v0.3.35/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
+github.com/hrfee/mediabrowser v0.3.36 h1:erYWzmaz4b6wfxEfeEWQHLMI9fSpGDy1m7NxkQmIVsw=
+github.com/hrfee/mediabrowser v0.3.36/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
github.com/hrfee/simple-template v1.1.0 h1:PNQDTgc2H0s19/pWuhRh4bncuNJjPrW0fIX77YtY78M=
github.com/hrfee/simple-template v1.1.0/go.mod h1:s9a5QgfqbmT7j9WCC3GD5JuEqvihBEohyr+oYZmr4bA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
diff --git a/html/admin.html b/html/admin.html
index 919266b..d14a053 100644
--- a/html/admin.html
+++ b/html/admin.html
@@ -806,54 +806,59 @@
{{ .strings.sendPWR }}
{{ .quantityStrings.deleteUser.Singular }}
-