added events to event system

This commit is contained in:
2025-05-31 19:07:29 +02:00
parent 224d4d400e
commit 2c9b302a69
12 changed files with 309 additions and 112 deletions

View File

@@ -10,7 +10,7 @@ import logging
import sys
import time
from forms import CompanySettingsForm
from utils import log_event
from utils import log_event, create_notification
# Set up logging to show in console
logging.basicConfig(
@@ -55,7 +55,7 @@ def init_routes(main_bp):
Event.user_id == current_user.id, # User's own actions
db.and_(
Event.event_type.in_(['conversation_create', 'message_create']), # Conversation-related events
Event.details['conversation_id'].astext.in_(
Event.details['conversation_id'].cast(db.Integer).in_(
db.session.query(Conversation.id)
.join(Conversation.members)
.filter(User.id == current_user.id)
@@ -370,6 +370,17 @@ def init_routes(main_bp):
flash('Passwords do not match.', 'error')
return render_template('profile/profile.html')
current_user.set_password(new_password)
# Create password change notification
create_notification(
notif_type='password_changed',
user_id=current_user.id,
details={
'message': 'Your password has been changed successfully.',
'timestamp': datetime.utcnow().isoformat()
}
)
flash('Password updated successfully.', 'success')
elif confirm_password:
flash('Please enter a new password.', 'error')
@@ -522,7 +533,8 @@ def init_routes(main_bp):
'details': notif.details,
'sender': {
'id': notif.sender.id,
'username': notif.sender.username
'username': notif.sender.username,
'last_name': notif.sender.last_name
} if notif.sender else None
} for notif in notifications.items],
'total_pages': total_pages,