Store hashed ips. Display unique ip count in catalog

This commit is contained in:
Dominic Ferrando
2025-04-20 20:54:34 -04:00
parent 1148648aa4
commit c8b549115a
6 changed files with 63 additions and 19 deletions
+3 -3
View File
@@ -150,7 +150,7 @@ func main() {
return
}
if err := database.PutThread(db, slug, subject, body, filename); err != nil {
if err := database.PutThread(db, slug, subject, body, filename, util.HashIp(ip)); err != nil {
http.Error(w, "Failed to create thread", http.StatusInternalServerError)
log.Printf("PutThread: %v", err)
return
@@ -201,7 +201,7 @@ func main() {
mediaPath = filename
}
if err := database.PutPost(db, threadId, body, mediaPath); err != nil {
if err := database.PutPost(db, threadId, body, mediaPath, util.HashIp(ip)); err != nil {
http.Error(w, "Failed to create post", http.StatusInternalServerError)
log.Printf("PutPost: %v", err)
return
@@ -246,7 +246,7 @@ func main() {
ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id),
MediaPath: op.MediaPath,
ReplyCount: len(posts),
IpCount: 0, // TODO
IpCount: util.SumUniquePostIps(posts),
})
}