use login context with newmessage
This commit is contained in:
@@ -115,11 +115,14 @@ func NewMessage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
userID := r.FormValue("user_id")
|
||||
if userID == "" {
|
||||
http.Error(w, "Invalid user ID", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// userID := r.FormValue("user_id")
|
||||
//if userID == "" {
|
||||
// http.Error(w, "Invalid user ID", http.StatusBadRequest)
|
||||
// return
|
||||
//}
|
||||
|
||||
var user = r.Context().Value(userKey{}).(*User)
|
||||
|
||||
body := r.FormValue("body")
|
||||
|
||||
if body == "" {
|
||||
@@ -129,7 +132,7 @@ func NewMessage(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
msg := Message{
|
||||
ID: newMessageID(),
|
||||
UserID: userID,
|
||||
UserID: user.ID,
|
||||
Body: body,
|
||||
Timestamp: time.Now(),
|
||||
Edited: time.Time{},
|
||||
|
Reference in New Issue
Block a user