fox more event logging
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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()
|
||||
|
||||
|
||||
@@ -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('/<int:room_id>/files/<filename>', 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('/<int:room_id>/files/<path:filename>', 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('/<int:room_id>/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})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user