Skip to content

Commit

Permalink
Add info logs about file sharing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LoanR committed Apr 24, 2024
1 parent 31f000a commit 7a5d84c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions web/b3desk/endpoints/meeting_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def insertDocuments(meeting: Meeting):
filehash = hashlib.sha1(
f"{secret_key}-1-{id}-{secret_key}".encode()
).hexdigest()
current_app.logger.info(
"Call insert document BigBlueButton API in running room for %s", filename
)
url = url_for(
"meeting_files.ncdownload",
isexternal=1,
Expand Down Expand Up @@ -552,6 +555,9 @@ def insertDoc(token):
)
xml = f"<?xml version='1.0' encoding='UTF-8'?> <modules> <module name='presentation'><document url='{url}' filename='{meeting_file.title}' /> </module></modules>"

current_app.logger.info(
"Call insert document BigBlueButton API for %s", meeting_file.title
)
requests.post(
f"{current_app.config['BIGBLUEBUTTON_ENDPOINT']}/insertDocument",
data=xml,
Expand All @@ -565,6 +571,7 @@ def insertDoc(token):
@bp.route("/ncdownload/<int:isexternal>/<mfid>/<mftoken>")
@bp.route("/ncdownload/<int:isexternal>/<mfid>/<mftoken>/<filename>")
def ncdownload(isexternal, mfid, mftoken, filename=None):
current_app.logger.info("Service requesting file url %s", filename)
secret_key = current_app.config["SECRET_KEY"]
# select good file from token
# get file through NC credentials - HOW POSSIBLE ?
Expand Down
4 changes: 4 additions & 0 deletions web/b3desk/models/bbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def meeting_file_addition_xml(self, meeting_files):
filehash = hashlib.sha1(
f"{current_app.config['SECRET_KEY']}-0-{meeting_file.id}-{current_app.config['SECRET_KEY']}".encode()
).hexdigest()
current_app.logger.info(
"Add document on BigBLueButton room creation for file",
meeting_file.title,
)
url = url_for(
"meeting_files.ncdownload",
isexternal=0,
Expand Down
13 changes: 11 additions & 2 deletions web/b3desk/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_user_nc_credentials(username):
or not current_app.config["FILE_SHARING"]
or not username
):
current_app.logger.debug(
current_app.logger.info(
"File sharing deactivated or unable to perform, no connection to Nextcloud instance"
)
return {"nctoken": None, "nclocator": None, "nclogin": None}
Expand Down Expand Up @@ -87,10 +87,15 @@ def update_user_nc_credentials(user, user_info):
and user.nc_locator
and user.nc_token
and (
(datetime.now() - user.nc_last_auto_enroll).days
(remaining_time := (datetime.now() - user.nc_last_auto_enroll)).days
<= current_app.config["NC_LOGIN_TIMEDELTA_DAYS"]
)
):
current_app.logger.info(
"Nextcloud login for user %s not to be refreshed for %s",
user,
remaining_time,
)
return False

preferred_username = (
Expand All @@ -104,8 +109,12 @@ def update_user_nc_credentials(user, user_info):
or data["nclocator"] is None
or data["nctoken"] is None
):
current_app.logger.info(
"No new Nextcloud enroll needed for user %s with those data %s", user, data
)
nc_last_auto_enroll = None
else:
current_app.logger.info("New Nextcloud enroll for user %s", data["nclogin"])
nc_last_auto_enroll = datetime.now()

user.nc_locator = data["nclocator"]
Expand Down

0 comments on commit 7a5d84c

Please sign in to comment.