This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-16 01:27:52 -04:00
1 parent 200d447f62
commit cf235738f5
7 files changed
+186 -126

No files matched your search

+16 -32
View File
@@ -647,40 +647,24 @@ async def _check_calendar_alerts(app) -> None:
except Exception:
log.debug(f'Failed to mark event {event.id} as alerted', exc_info=True)
# Send webhook notification if user has one configured
# Send target notification if user has one configured
try:
webui_name = getattr(app.state, 'WEBUI_NAME', 'Open WebUI')
enable_user_webhooks = await Config.get('ui.enable_user_webhooks')
if enable_user_webhooks:
user = await Users.get_user_by_id(event.user_id)
if user and user.settings:
webhook_url = (
user.settings.get('ui', {}).get('notifications', {}).get('webhook_url', None)
if isinstance(user.settings, dict)
else getattr(getattr(user.settings, 'ui', None), 'get', lambda *a: None)(
'notifications', {}
).get('webhook_url', None)
if hasattr(user.settings, 'ui')
else None
)
if webhook_url:
from open_webui.utils.webhook import post_webhook
time_str = f'in {minutes_until} min' if minutes_until > 0 else 'now'
await post_webhook(
webui_name,
webhook_url,
f'{event.title} — starting {time_str}',
{
'action': 'calendar_alert',
'title': event.title,
'minutes_until': minutes_until,
'event_id': event.id,
},
)
time_str = f'in {minutes_until} min' if minutes_until > 0 else 'now'
await publish_event(
app,
EVENTS.CALENDAR_ALERT,
subject_id=event.id,
subject_type='calendar.event',
source='scheduler',
data={
**alert_data,
'user_id': event.user_id,
'message': f'{event.title} — starting {time_str}',
},
message=event.title,
)
except Exception:
log.debug(f'Failed to send webhook for calendar alert {event.id}', exc_info=True)
log.debug(f'Failed to send notification for calendar alert {event.id}', exc_info=True)
async def _record_run(