'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.
This commit is contained in:
Noah Petherbridge 2024-09-26 20:56:16 -07:00
parent 7aa1d512fc
commit ab880148ad
3 changed files with 25 additions and 15 deletions

View File

@ -118,6 +118,11 @@ func Likes() http.HandlerFunc {
return 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 targetUser = user
} }
} else { } else {

View File

@ -26,6 +26,7 @@ func Contact() http.HandlerFunc {
subject = r.FormValue("subject") subject = r.FormValue("subject")
title = "Contact Us" title = "Contact Us"
message = r.FormValue("message") message = r.FormValue("message")
footer string // appends to the message only when posting the feedback
replyTo = r.FormValue("email") replyTo = r.FormValue("email")
trap1 = r.FormValue("url") != "https://" trap1 = r.FormValue("url") != "https://"
trap2 = r.FormValue("comment") != "" trap2 = r.FormValue("comment") != ""
@ -74,6 +75,14 @@ func Contact() http.HandlerFunc {
case "report.message": case "report.message":
tableName = "messages" tableName = "messages"
tableLabel = "Direct Message conversation" 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": case "report.comment":
tableName = "comments" tableName = "comments"
@ -141,7 +150,7 @@ func Contact() http.HandlerFunc {
fb := &models.Feedback{ fb := &models.Feedback{
Intent: intent, Intent: intent,
Subject: subject, Subject: subject,
Message: message, Message: message + footer,
TableName: tableName, TableName: tableName,
TableID: uint64(tableID), TableID: uint64(tableID),
} }

View File

@ -69,18 +69,7 @@
the main website and the chat room. the main website and the chat room.
</div> </div>
<div class="columns is-mobile"> <button type="submit" class="button is-success">Send Reply</button>
<div class="column">
<button type="submit" class="button is-success">Send Reply</button>
</div>
<div class="column is-narrow">
<a href="/contact?intent=report&subject=report.message&id={{.MessageID}}"
class="button has-text-danger ml-4">
<span class="icon"><i class="fa fa-flag"></i></span>
<span>Report</span>
</a>
</div>
</div>
</form> </form>
@ -151,15 +140,22 @@
<!-- Our message? We can delete it. --> <!-- Our message? We can delete it. -->
{{if eq $Root.CurrentUser.ID $SourceUser.ID}} {{if eq $Root.CurrentUser.ID $SourceUser.ID}}
<form action="/messages/delete" method="POST" class="is-inline" onsubmit="return confirm('Delete this message?')"> <form action="/messages/delete" method="POST" class="is-inline"
onsubmit="return confirm('Do you want to DELETE this message?')">
{{InputCSRF}} {{InputCSRF}}
<input type="hidden" name="id" value="{{.ID}}"> <input type="hidden" name="id" value="{{.ID}}">
<input type="hidden" name="next" value="{{$Root.Request.URL.Path}}"> <input type="hidden" name="next" value="{{$Root.Request.URL.Path}}">
<button class="button has-text-danger is-outline is-small p-1 ml-4"> <button class="button is-outline has-text-grey is-small ml-4">
<i class="fa fa-trash mr-2"></i> <i class="fa fa-trash mr-2"></i>
Delete Delete
</button> </button>
</form> </form>
{{else}}
<a href="/contact?intent=report&subject=report.message&id={{.ID}}"
class="button is-outline is-small has-text-danger ml-4">
<span class="icon"><i class="fa fa-flag"></i></span>
<span>Report</span>
</a>
{{end}} {{end}}
</div> </div>