Skip to content

Commit b947f26

Browse files
committed
Merge branch '355-chat' of https://github.com/Seluj78/PyMatcha into 355-chat
2 parents 9c47a71 + 3e7b81a commit b947f26

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

backend/PyMatcha/models/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def get_matches(self):
305305
return match_list
306306

307307
def send_message(self, to_id, content):
308-
Message.create(from_id=self.id, to_id=to_id, content=content)
308+
Message.create(from_id=self.id, to_id=to_id, content=content, timestamp=datetime.datetime.utcnow())
309309

310310
def get_messages(self) -> List[Message]:
311311
with self.db.cursor() as c:

backend/PyMatcha/routes/api/messages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from PyMatcha.utils.errors import NotFoundError
3131
from PyMatcha.utils.success import Success
3232
from PyMatcha.utils.success import SuccessOutput
33+
from PyMatcha.utils.success import SuccessOutputMessage
3334
from timeago import format as timeago_format
3435

3536

@@ -73,7 +74,8 @@ def send_message():
7374

7475
current_user.send_message(to_id=to_user.id, content=content)
7576
current_app.logger.debug("/messages -> Message successfully sent to {}.".format(to_uid))
76-
return Success("Message successfully sent to {}.".format(to_uid))
77+
new_message = Message.get_multis(to_id=to_user.id, content=content, from_id=current_user.id)[-1]
78+
return SuccessOutputMessage("new_message", new_message.to_dict(), "Message successfully sent to {}.".format(to_uid))
7779

7880

7981
@messages_bp.route("/conversations/<with_uid>", methods=["GET"])

0 commit comments

Comments
 (0)