diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index 434b637..88e91f3 100644 Binary files a/__pycache__/models.cpython-313.pyc and b/__pycache__/models.cpython-313.pyc differ 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 35f2872..7b749cf 100644 Binary files a/routes/__pycache__/conversations.cpython-313.pyc and b/routes/__pycache__/conversations.cpython-313.pyc differ diff --git a/routes/__pycache__/room_files.cpython-313.pyc b/routes/__pycache__/room_files.cpython-313.pyc index a06282a..1d28c1b 100644 Binary files a/routes/__pycache__/room_files.cpython-313.pyc and b/routes/__pycache__/room_files.cpython-313.pyc differ diff --git a/routes/__pycache__/rooms.cpython-313.pyc b/routes/__pycache__/rooms.cpython-313.pyc index 7e72093..e229609 100644 Binary files a/routes/__pycache__/rooms.cpython-313.pyc and b/routes/__pycache__/rooms.cpython-313.pyc differ 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' %}