diff --git a/src/templates/src/admin_approval_queue.html b/src/templates/src/admin_approval_queue.html
index 5b7905ae..d39bf487 100644
--- a/src/templates/src/admin_approval_queue.html
+++ b/src/templates/src/admin_approval_queue.html
@@ -1,5 +1,13 @@
{{ template "base.html" . }}
+{{ define "extrahead" }}
+
+{{ end }}
+
{{ define "content" }}
{{ range .UnapprovedUsers }}
@@ -75,28 +83,8 @@
{{ end }}
- {{ range .Posts }}
-
-
-
-
-
-
{{ .Title }}
- {{ timehtml (relativedate .PostDate) .PostDate }}
- {{ if and $.User.IsStaff .IP }}
-
[{{ .IP }}]
- {{ end }}
-
-
-
- {{ .Content }}
-
-
-
+ {{ range .Timeline }}
+ {{ template "timeline_item.html" . }}
{{ end }}
diff --git a/src/website/admin.go b/src/website/admin.go
index b315fbbb..29c14c87 100644
--- a/src/website/admin.go
+++ b/src/website/admin.go
@@ -5,6 +5,7 @@ import (
"encoding/base64"
"errors"
"fmt"
+ "html/template"
"net/http"
"sort"
"strconv"
@@ -128,8 +129,8 @@ type unapprovedUserData struct {
User templates.User
Date time.Time
UserLinks []templates.Link
- Posts []postWithTitle
ProjectsWithLinks []projectWithLinks
+ Timeline []templates.TimelineItem
}
func AdminApprovalQueue(c *RequestContext) ResponseData {
@@ -138,6 +139,25 @@ func AdminApprovalQueue(c *RequestContext) ResponseData {
lineageBuilder := models.MakeSubforumLineageBuilder(subforumTree)
c.Perf.EndBlock()
+ potentialUsers, err := db.QueryScalar[int](c, c.Conn,
+ `
+ SELECT id
+ FROM hmn_user
+ WHERE hmn_user.status = $1
+ `,
+ models.UserStatusConfirmed,
+ )
+ if err != nil {
+ return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch unapproved users"))
+ }
+
+ snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{
+ OwnerIDs: potentialUsers,
+ })
+ if err != nil {
+ return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch unapproved snippets"))
+ }
+
posts, err := fetchUnapprovedPosts(c)
if err != nil {
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch unapproved posts"))
@@ -151,6 +171,28 @@ func AdminApprovalQueue(c *RequestContext) ResponseData {
unapprovedUsers := make([]*unapprovedUserData, 0)
userIDToDataIdx := make(map[int]int)
+ for _, s := range snippets {
+ var userData *unapprovedUserData
+ if idx, ok := userIDToDataIdx[s.Owner.ID]; ok {
+ userData = unapprovedUsers[idx]
+ } else {
+ userData = &unapprovedUserData{
+ User: templates.UserToTemplate(s.Owner, c.Theme),
+ UserLinks: make([]templates.Link, 0, 10),
+ }
+ unapprovedUsers = append(unapprovedUsers, userData)
+ userIDToDataIdx[s.Owner.ID] = len(unapprovedUsers) - 1
+ }
+
+ if s.Snippet.When.After(userData.Date) {
+ userData.Date = s.Snippet.When
+ }
+ timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false)
+ timelineItem.OwnerAvatarUrl = ""
+ timelineItem.SmallInfo = true
+ userData.Timeline = append(userData.Timeline, timelineItem)
+ }
+
for _, p := range posts {
var userData *unapprovedUserData
if idx, ok := userIDToDataIdx[p.Author.ID]; ok {
@@ -167,13 +209,11 @@ func AdminApprovalQueue(c *RequestContext) ResponseData {
if p.Post.PostDate.After(userData.Date) {
userData.Date = p.Post.PostDate
}
- post := templates.PostToTemplate(&p.Post, &p.Author, c.Theme)
- post.AddContentVersion(p.CurrentVersion, &p.Author) // NOTE(asaf): Don't care about editors here
- post.Url = UrlForGenericPost(hmndata.UrlContextForProject(&p.Project), &p.Thread, &p.Post, lineageBuilder)
- userData.Posts = append(userData.Posts, postWithTitle{
- Post: post,
- Title: p.Thread.Title,
- })
+ timelineItem := PostToTimelineItem(hmndata.UrlContextForProject(&p.Project), lineageBuilder, &p.Post, &p.Thread, &p.Author, c.Theme)
+ timelineItem.OwnerAvatarUrl = ""
+ timelineItem.SmallInfo = true
+ timelineItem.Description = template.HTML(p.CurrentVersion.TextParsed)
+ userData.Timeline = append(userData.Timeline, timelineItem)
}
for _, p := range projects {