From ab880148ad18dd9648477b6216ee135e20cf6d27 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Thu, 26 Sep 2024 20:56:16 -0700 Subject: [PATCH] 'Likes' view an image + Tweak inbox page * Hitting the Like button on a photo will mark it as viewed. * Move the 'Report' button on the message inbox page, to instead be in the footer of each DM. * Improve message reporting behavior to include the content of the message in the admin report. --- pkg/controller/api/likes.go | 5 +++++ pkg/controller/index/contact.go | 11 ++++++++++- web/templates/inbox/inbox.html | 24 ++++++++++-------------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/pkg/controller/api/likes.go b/pkg/controller/api/likes.go index 2748225..53df2ac 100644 --- a/pkg/controller/api/likes.go +++ b/pkg/controller/api/likes.go @@ -118,6 +118,11 @@ func Likes() http.HandlerFunc { return } + // Mark this photo as 'viewed' if it received a like. + // Example: on a gallery view the photo is only 'viewed' if interacted with (lightbox), + // going straight for the 'Like' button should count as well. + photo.View(currentUser.ID) + targetUser = user } } else { diff --git a/pkg/controller/index/contact.go b/pkg/controller/index/contact.go index 2dd6abe..c507ab6 100644 --- a/pkg/controller/index/contact.go +++ b/pkg/controller/index/contact.go @@ -26,6 +26,7 @@ func Contact() http.HandlerFunc { subject = r.FormValue("subject") title = "Contact Us" message = r.FormValue("message") + footer string // appends to the message only when posting the feedback replyTo = r.FormValue("email") trap1 = r.FormValue("url") != "https://" trap2 = r.FormValue("comment") != "" @@ -74,6 +75,14 @@ func Contact() http.HandlerFunc { case "report.message": tableName = "messages" tableLabel = "Direct Message conversation" + + // Find this message, and attach it to the report. + if msg, err := models.GetMessage(uint64(tableID)); err == nil { + footer = fmt.Sprintf( + "\n\n---\n\nThe reported DM said:\n\n%s", + markdown.Quotify(msg.Message), + ) + } case "report.comment": tableName = "comments" @@ -141,7 +150,7 @@ func Contact() http.HandlerFunc { fb := &models.Feedback{ Intent: intent, Subject: subject, - Message: message, + Message: message + footer, TableName: tableName, TableID: uint64(tableID), } diff --git a/web/templates/inbox/inbox.html b/web/templates/inbox/inbox.html index 9133038..29637fb 100644 --- a/web/templates/inbox/inbox.html +++ b/web/templates/inbox/inbox.html @@ -69,18 +69,7 @@ the main website and the chat room. -
-
- -
- -
+ @@ -151,15 +140,22 @@ {{if eq $Root.CurrentUser.ID $SourceUser.ID}} -
+ {{InputCSRF}} -
+ {{else}} + + + Report + {{end}}