From afe05ff429e22f8ca5306a3679db2b6363dc54f4 Mon Sep 17 00:00:00 2001 From: quimmrc Date: Thu, 21 Nov 2024 15:27:00 +0100 Subject: [PATCH] check whether if request user is coincident with "from" or "to" user and decide the recipient accordingly --- messages/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/messages/views.py b/messages/views.py index f090ef029..d5f3cc92c 100644 --- a/messages/views.py +++ b/messages/views.py @@ -166,7 +166,11 @@ def new_message(request, username=None, message_id=None): if message.user_from != request.user and message.user_to != request.user: raise Http404 - + elif message.user_from == request.user: + to = message.user_to.username + else: + to = message.user_from.username + body = message.body.body.replace("\r\n", "\n").replace("\r", "\n") body = quote_message_for_reply(body, message.user_from.username)