Skip to content

Commit a614fd0

Browse files
committed
Added debug route for messages
1 parent c6ab7a3 commit a614fd0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

backend/PyMatcha/routes/api/debug.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from PyMatcha import redis
1010
from PyMatcha.models.like import Like
1111
from PyMatcha.models.match import Match
12+
from PyMatcha.models.message import Message
1213
from PyMatcha.models.report import Report
1314
from PyMatcha.models.tag import Tag
1415
from PyMatcha.models.user import get_user
@@ -141,11 +142,27 @@ def delete_matches():
141142
View.drop_table()
142143
User.drop_table()
143144
Tag.drop_table()
145+
Message.drop_table()
144146

145147
Match.create_table()
146148
Like.create_table()
147149
Report.create_table()
148150
View.create_table()
149151
User.create_table()
150152
Tag.create_table()
153+
Message.create_table()
154+
return "", 204
155+
156+
157+
DEBUG_SEND_MESSAGE = {"from_uid": str, "to_uid": str, "content": str}
158+
159+
160+
@debug_bp.route("/debug/messages/send", methods=["POST"])
161+
@debug_token_required
162+
@validate_params(DEBUG_SEND_MESSAGE)
163+
def debug_send_message():
164+
data = request.get_json()
165+
from_id = get_user(data["from_uid"]).id
166+
to_id = get_user(data["to_uid"]).id
167+
Message.create(from_id=from_id, to_id=to_id, content=data["content"])
151168
return "", 204

0 commit comments

Comments
 (0)