Fix compose page when replying to messages

This commit is contained in:
Noah Petherbridge 2023-09-25 18:13:13 -07:00
parent 8456c5d0f5
commit e5b5b9435b

View File

@ -41,12 +41,6 @@ func Compose() http.HandlerFunc {
return return
} }
// If we already have a thread open with them, go to that instead of the stand-alone compose page.
if msgID, ok := models.HasMessageThread(currentUser, user); ok {
templates.Redirect(w, fmt.Sprintf("/messages/read/%d", msgID))
return
}
// POSTing? // POSTing?
if r.Method == http.MethodPost { if r.Method == http.MethodPost {
var ( var (
@ -75,6 +69,12 @@ func Compose() http.HandlerFunc {
return return
} }
// If we already have a thread open with them, go to that instead of the stand-alone compose page.
if msgID, ok := models.HasMessageThread(currentUser, user); ok {
templates.Redirect(w, fmt.Sprintf("/messages/read/%d", msgID))
return
}
// On GET request (come from a user profile page): // On GET request (come from a user profile page):
// Do not allow a shy user to initiate DMs with a non-shy one. // Do not allow a shy user to initiate DMs with a non-shy one.
var ( var (