From 50f7e115d691b9812b50977ab2f90b646979a199 Mon Sep 17 00:00:00 2001 From: Kobe Date: Fri, 30 May 2025 21:19:48 +0200 Subject: [PATCH] fox more event logging --- __pycache__/models.cpython-313.pyc | Bin 20672 -> 20720 bytes models.py | 1 + .../__pycache__/conversations.cpython-313.pyc | Bin 24171 -> 24703 bytes routes/__pycache__/room_files.cpython-313.pyc | Bin 45408 -> 47025 bytes routes/__pycache__/rooms.cpython-313.pyc | Bin 19080 -> 19080 bytes routes/conversations.py | 13 ++++++ routes/room_files.py | 43 ++++++++++++++++++ templates/settings/tabs/events.html | 6 +++ 8 files changed, 63 insertions(+) diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index 434b637a6430d1143515708d130018a3b05813f9..88e91f32944756208a89f51e9cdd9ab1c6d6278c 100644 GIT binary patch delta 213 zcmX@GknzJpM&8f7yj%=GP{(4GQM8eFlQUz_XQY0Wf?Ul>-qX|DKauJ6oH6e zliPeRFe*+C_j?E=E&XK~%{GVomoqA9FltO-`N9CCzJxIHF@`gCIQ4sUdVFO7v5Sm= G4gvtmhcR6M diff --git a/models.py b/models.py index b9d1cbc..e6e3866 100644 --- a/models.py +++ b/models.py @@ -236,6 +236,7 @@ class EventType(Enum): CONVERSATION_DELETE = 'conversation_delete' CONVERSATION_MEMBER_ADD = 'conversation_member_add' CONVERSATION_MEMBER_REMOVE = 'conversation_member_remove' + CONVERSATION_OPEN = 'conversation_open' # Message events MESSAGE_CREATE = 'message_create' diff --git a/routes/__pycache__/conversations.cpython-313.pyc b/routes/__pycache__/conversations.cpython-313.pyc index 35f2872d706469dbac04cea4d07225dc37a3eab6..7b749cf0337073630f04dce70766717294b21a11 100644 GIT binary patch delta 1438 zcmZuxZA_b06z*-`xAenyWx(39zJr#^cU&RKx+*fVy&#(5NP4HB{7Pu zKaBHZPCPMln$WvS3!TSvIvhn{#~Mqjfi__5GejeTY!38UJm9ATcE~Z zguylqd}1h+_L#AN)62X(476=~)yB!YEim3B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{sD6pGKr9=gOATh_5!xxzFq)XcuuSb<5|h!XRPWz zs}@;ANNj}VXQhlajMYCdS%b_ZCD91oXJ2;IvTqn&mQd0;u|kAxqgmh{EpjYlwGWh$ YPv=Ap@qcCaeM6O;;yJMy3eJ`O8^#F2MgRZ+ delta 1584 zcmaJ>YfzMB6yEpSZY%z){ovF&+a+TxxeTA zMt+heuSk}gX0uU)r~dZ^>v!%Nv7|VqkO7qPE^)~DhRi+^D>FNpkh4xOG3D}W*(&j< z2P7%M2HM;a`Z<$Z%K{=HFHOseAXw;vh$|5SM~q^ma06p0kk?{|^0EwQEM5#piktMY zOrvRAE-WP_Ofos4zVtEaD@n}A%Vpx)ynRf(v!F!M=aW%7SW41iyT<~qg;!;}#*_%o z@=8`LTFM4t?6WH+%~bgdK0s_B|eM_-i_dPVhyQKx}?YHHt~l@ z?L&yjKBZlW#H|ene15(rqy+u&?GkRBM6Q|AdxTPxD#54sS4s0@aUzOnuYK1bLaRhE~<;05$4!9s=$ISE> z$t<2g5R8&d%=EtTi_pHK+~~pBFH=v+G;R2P$8r04Lv~cJiH+NB?lFI1aC~NP>~H$q zkbPCwi@?(l=yY?@5z7G4!a7~M?2LRb711=+}Um_$&L`w^I$vo`?=beTKddCa9@j38oMt z%nvPn_&FM$sauN9FNulat=c$>!zBV4{9@heNwTMBr#=WyyU%GYIqe#!%i%O`P9x?t z1WpZcig;MVA0fww5h8|#!LY9*;IH5f;5>dRxt_5~c2ld75(sKoR8}?75ZpTMuw}5u zX|fhcQbdKgigs>5!F3s+wpM zoF3hlRLSlNS`n2=jxL6iV-DyT%eQ5*Mbo}WlN?>aV0`R#YyMrHloREs4>rG5`WL81 B$!P!p diff --git a/routes/__pycache__/rooms.cpython-313.pyc b/routes/__pycache__/rooms.cpython-313.pyc index 7e720930829ba268c28a799633fb6c0e823ff725..e229609b11fef301382f37db1a5ccd6336d1b7a6 100644 GIT binary patch delta 21 bcmeB}%GfcLk?S)rFBbz4gfngAs`CN>Ku85T delta 21 bcmeB}%GfcLk?S)rFBbz4yky+SRp$i&L$3wP diff --git a/routes/conversations.py b/routes/conversations.py index 523a9b7..c07de7d 100644 --- a/routes/conversations.py +++ b/routes/conversations.py @@ -114,6 +114,19 @@ def conversation(conversation_id): flash('You do not have access to this conversation.', 'error') return redirect(url_for('conversations.conversations')) + # Log conversation open + log_event( + event_type='conversation_open', + details={ + 'conversation_id': conversation.id, + 'conversation_name': conversation.name, + 'user_id': current_user.id, + 'user_name': f"{current_user.username} {current_user.last_name}", + 'message_count': Message.query.filter_by(conversation_id=conversation_id).count() + } + ) + db.session.commit() + # Query messages directly using the Message model messages = Message.query.filter_by(conversation_id=conversation_id).order_by(Message.created_at.asc()).all() diff --git a/routes/room_files.py b/routes/room_files.py index 17b8583..a836d0b 100644 --- a/routes/room_files.py +++ b/routes/room_files.py @@ -234,6 +234,7 @@ def upload_room_file(room_id): }, user_id=current_user.id ) + db.session.commit() return jsonify({'success': True, 'filename': filename, 'overwritten': True}) else: rf = RoomFile( @@ -260,6 +261,7 @@ def upload_room_file(room_id): }, user_id=current_user.id ) + db.session.commit() return jsonify({'success': True, 'filename': filename}) @room_files_bp.route('//files/', methods=['GET']) @@ -299,6 +301,7 @@ def download_room_file(room_id, filename): }, user_id=current_user.id ) + db.session.commit() return send_from_directory(os.path.dirname(file_path), filename, as_attachment=True) @room_files_bp.route('//files/', methods=['DELETE']) @@ -343,6 +346,7 @@ def delete_file(room_id, filename): }, user_id=current_user.id ) + db.session.commit() return jsonify({'success': True}) @@ -415,6 +419,18 @@ def create_room_folder(room_id): ) db.session.add(rf) db.session.commit() + + log_event( + event_type='folder_create', + details={ + 'created_by': f"{current_user.username} {current_user.last_name}", + 'folder_name': folder_name, + 'room_id': room_id, + 'path': rel_path + }, + user_id=current_user.id + ) + db.session.commit() return jsonify({'success': True, 'name': folder_name}) @room_files_bp.route('//rename', methods=['POST']) @@ -494,6 +510,7 @@ def rename_room_file(room_id): }, user_id=current_user.id ) + db.session.commit() return jsonify({'success': True, 'old_name': old_name, 'new_name': new_name}) @@ -633,6 +650,7 @@ def move_room_file(room_id): }, user_id=current_user.id ) + db.session.commit() return jsonify({'success': True}) @@ -701,9 +719,33 @@ def toggle_star(room_id): if is_starred: # Unstar the file rf.starred_by.remove(current_user) + log_event( + event_type='file_unstar', + details={ + 'unstarred_by': f"{current_user.username} {current_user.last_name}", + 'filename': filename, + 'room_id': room_id, + 'path': rel_path, + 'type': rf.type, + 'size': rf.size if rf.type == 'file' else None + }, + user_id=current_user.id + ) else: # Star the file rf.starred_by.append(current_user) + log_event( + event_type='file_star', + details={ + 'starred_by': f"{current_user.username} {current_user.last_name}", + 'filename': filename, + 'room_id': room_id, + 'path': rel_path, + 'type': rf.type, + 'size': rf.size if rf.type == 'file' else None + }, + user_id=current_user.id + ) db.session.commit() @@ -914,6 +956,7 @@ def restore_file(room_id): }, user_id=current_user.id ) + db.session.commit() return jsonify({'success': True}) diff --git a/templates/settings/tabs/events.html b/templates/settings/tabs/events.html index f9033c8..e961d64 100644 --- a/templates/settings/tabs/events.html +++ b/templates/settings/tabs/events.html @@ -19,6 +19,7 @@ + @@ -26,6 +27,7 @@ + @@ -88,6 +90,8 @@ File Unstar {% elif event.event_type == 'file_delete_permanent' %} File Delete Permanent + {% elif event.event_type == 'folder_create' %} + Folder Create {% elif event.event_type == 'room_create' %} Room Create {% elif event.event_type == 'room_delete' %} @@ -102,6 +106,8 @@ Conversation Create {% elif event.event_type == 'conversation_delete' %} Conversation Delete + {% elif event.event_type == 'conversation_open' %} + Conversation Open {% elif event.event_type == 'message_sent' %} Message Sent {% elif event.event_type == 'attachment_download' %}