WIP: Starting to make messages in receive mode work in GUI

This commit is contained in:
Micah Lee 2021-04-28 19:10:26 -04:00
parent b343d391b3
commit ea17eacf43
5 changed files with 62 additions and 7 deletions

View file

@ -26,6 +26,17 @@ from datetime import datetime
from flask import Request, request, render_template, make_response, flash, redirect
from werkzeug.utils import secure_filename
"""
Receive mode uses a special flask requests object, ReceiveModeRequest, in
order to keep track of upload progress. Here's what happens when someone
uploads files:
- new ReceiveModeRequest object is created
- creates a directory based on the timestamp
-
"""
class ReceiveModeWeb:
"""
@ -90,18 +101,20 @@ class ReceiveModeWeb:
with open(local_path, "w") as f:
f.write(text_message)
basename = os.path.basename(local_path)
# TODO: possibly change this
# Tell the GUI a message has been uploaded
self.web.add_request(
self.web.REQUEST_UPLOAD_SET_DIR,
request.path,
self.web.REQUEST_STARTED,
local_path,
{
"id": request.history_id,
"filename": basename,
"dir": request.receive_mode_dir,
"content_length": len(text_message),
},
)
self.web.add_request(
self.web.REQUEST_UPLOAD_FINISHED,
local_path,
{"id": request.history_id},
)
self.common.log(
"ReceiveModeWeb",