Skip to content

Commit e526bb2

Browse files
committed
Merge feature/notification-system: Release v1.3.0
Merges complete notification system implementation with 12 notification types. Features: - Portal Notifications (4 types) - ticket updates for all users - Agent Notifications (8 types) - SLA warnings, assignments, team queue - Weekend-aware SLA detection (Friday 72h, Saturday 48h) - Crossing-time algorithm (no duplicate warnings) - 3-state admin configuration (disabled/forced/user_choice) - Query optimization and rate limiting - Complete documentation and translations (EN, DE, FR) See CHANGELOG.md for detailed release notes.
2 parents 4aff5be + d76cae7 commit e526bb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+8269
-1019
lines changed

CHANGELOG.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,157 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
---
99

10+
## [1.3.0] - 2025-11-08
11+
12+
### ✨ Major New Feature: Agent Notifications System
13+
14+
Version 1.3.0 introduces a comprehensive notification system with **12 notification types** across two independent tracks: Portal (4 types) and Agent (8 types). The system provides smart, event-driven notifications with weekend-aware SLA warnings and zero duplicate detection.
15+
16+
### Added
17+
18+
#### Agent Notification System (8 Types)
19+
- **Ticket Assignment Tracking**:
20+
- `ticket_assigned`: New tickets assigned to you from unassigned state
21+
- `ticket_reassigned`: Tickets reassigned to you from another agent
22+
- `team_unassigned_new`: New unassigned tickets appearing in your team's queue
23+
24+
- **SLA Management**:
25+
- `ticket_tto_warning`: Time To Own SLA warnings with escalating urgency (⏰ 24h → ⚠️ 12h → 🟠 4h → 🔴 1h)
26+
- `ticket_ttr_warning`: Time To Resolve SLA warnings with same escalation pattern
27+
- `ticket_sla_breach`: SLA deadline exceeded alerts (🚨 icon)
28+
- **Weekend-Aware Logic**: Friday uses 72h threshold, Saturday uses 48h threshold to catch Monday/Tuesday breaches
29+
30+
- **Priority & Comments**:
31+
- `ticket_priority_critical`: Automatic alerts when tickets escalate to critical priority (🔴 icon)
32+
- `ticket_comment`: New comments on your tickets (both public and private log types)
33+
34+
#### Portal Notification Enhancements
35+
- Portal notifications (from v1.2.2) now fully integrated with agent system:
36+
- `ticket_status_changed`: Status transitions
37+
- `agent_responded`: Public comments from agents
38+
- `ticket_resolved`: Resolution notifications
39+
- `agent_assigned`: Agent assignment changes
40+
41+
#### Background Job Infrastructure
42+
- **CheckAgentTicketUpdates**: New background job running every 5 minutes
43+
- Processes all 8 agent notification types
44+
- Portal-only filtering (skips users with `is_portal_only='1'`)
45+
- Per-user interval checking (5-1440 minutes configurable)
46+
- Query optimization (skips API calls when notification types disabled)
47+
- Rate limiting (max 20 notifications per user per run)
48+
49+
- **CheckPortalTicketUpdates**: Existing job (enhanced)
50+
- Improved query optimization
51+
- Better timestamp handling
52+
- Contact role filtering support
53+
54+
#### Admin Configuration
55+
- **3-State Notification Control**: Configure each notification type independently
56+
- **Disabled**: Not available to users (hidden)
57+
- **Forced**: Mandatory for all users (no opt-out)
58+
- **User Choice**: Enabled by default, users can opt-out
59+
60+
- **Default Configuration**:
61+
- Portal: All 4 types set to "User Choice"
62+
- Agent: 6 types "User Choice", 2 types "Forced" (SLA breach, priority critical)
63+
64+
- **Configurable Intervals**:
65+
- Admin default: 5-1440 minutes (recommended: 15 minutes)
66+
- Per-user override available in personal settings
67+
68+
#### OCC Commands
69+
- **Enhanced `itop:notifications:test-user`**:
70+
- New `--agent` flag for testing agent notifications
71+
- New `--portal` flag for testing portal notifications (default)
72+
- `--reset` flag to clear timestamps and force full re-check
73+
- Displays user configuration, enabled notifications, and next execution time
74+
75+
#### API & Services
76+
- **New ItopAPIService Methods**:
77+
- `getAgentTicketIds()`: Get tickets assigned to agent
78+
- `getTicketsApproachingDeadline()`: SLA warning detection with crossing-time algorithm
79+
- `getTeamAssignmentChanges()`: Detect new unassigned team tickets
80+
- `applyCrossingTimeAlgorithm()`: Weekend-aware threshold calculation (private)
81+
82+
- **Team Detection**:
83+
- Leverages existing `getUserTeams()` method
84+
- Tracks `team_id` changes via CMDBChangeOp
85+
- Verifies tickets remain unassigned (`agent_id = NULL/0`)
86+
87+
#### Documentation
88+
- **New docs/NOTIFICATIONS.md**: Comprehensive 345-line user & admin guide
89+
- Complete notification type reference with examples
90+
- Setup instructions for users and administrators
91+
- Troubleshooting section with common issues
92+
- FAQ with 12 frequently asked questions
93+
- Technical architecture details
94+
95+
### Changed
96+
97+
#### Notification Algorithm Improvements
98+
- **SLA Crossing-Time Algorithm**: Detects threshold crossings without storing per-ticket state
99+
- Eliminates duplicate warnings for same SLA level
100+
- Dynamically calculates when each threshold (24h/12h/4h/1h) will be crossed
101+
- Only notifies most urgent level if multiple thresholds crossed
102+
- Weekend expansion: Friday (72h), Saturday (48h) for 24h threshold
103+
104+
- **Notification Deduplication**:
105+
- Unique object keys: `ticket_id|subject|timestamp_hash`
106+
- Timestamp filtering prevents re-processing old changes
107+
- Leverages Nextcloud's native duplicate prevention
108+
109+
#### User Experience
110+
- **Personal Settings UI**: Agent notifications section (only visible to non-portal users)
111+
- Master toggle for agent notifications
112+
- Granular per-type checkboxes (only "User Choice" types shown)
113+
- Info box listing "Forced" notifications that cannot be disabled
114+
- Integrated with existing portal notification settings
115+
116+
- **Notification Display**:
117+
- Escalating emoji icons based on urgency (SLA warnings)
118+
- Clear differentiation between public and private comments
119+
- Team name included in team ticket notifications
120+
- Clickable links route to appropriate iTop interface (portal vs admin UI)
121+
122+
### Technical Details
123+
124+
#### New Configuration Keys (oc_appconfig)
125+
- `agent_notification_config`: JSON map of notification type → state (disabled/forced/user_choice)
126+
- `default_notification_interval`: Default check interval for all users (minutes, default: 15)
127+
128+
#### New User Preferences (oc_preferences)
129+
- `notification_last_agent_check`: Unix timestamp of last agent notification check
130+
- `disabled_agent_notifications`: JSON array of disabled notification types OR "all"
131+
- `notification_check_interval`: Per-user custom interval (minutes)
132+
133+
#### Architecture Highlights
134+
- **Dual Background Jobs**: Portal and Agent jobs run independently
135+
- **CMDBChangeOp Detection**: Leverages iTop's built-in change tracking (no external state)
136+
- **Minimal State Storage**: Only timestamps per user (no per-ticket data)
137+
- **Query Optimization**: Early exit if all notifications disabled, selective API calls
138+
- **Portal-Only Filtering**: Agent job automatically skips portal-only users
139+
140+
#### Performance
141+
- **Per-User Intervals**: Users only processed when their interval elapses (reduces API load)
142+
- **Query Optimization**: Up to 100% reduction in API calls when notification types disabled
143+
- **Rate Limiting**: Max 20 notifications per user per run prevents spam
144+
- **Smart Caching**: Team memberships cached for 30 minutes, agent names for 24 hours
145+
146+
#### Translation Updates
147+
- Updated en.json, de.json, de_DE.json, fr.json with agent notification types
148+
149+
### Breaking Changes
150+
None - Existing portal notifications continue working without changes.
151+
152+
### Migration Notes
153+
- **No user action required**: Portal notifications work as before
154+
- **Agent detection automatic**: Users with `is_portal_only='0'` gain agent notification access
155+
156+
### See Also
157+
- [Complete Notification Guide](docs/NOTIFICATIONS.md)
158+
159+
---
160+
10161
## [1.2.2] - 2025-11-02
11162

12163
### Changed

README.md

Lines changed: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
🎟️ **Complete iTop ITSM & CMDB Integration** - Seamlessly access tickets, incidents, and Configuration Items from your Nextcloud environment
44

5-
[![Version](https://img.shields.io/badge/version-1.2.0-blue)](https://github.com/lexioj/integration_itop/releases)
5+
[![Version](https://img.shields.io/badge/version-1.3.0-blue)](https://github.com/lexioj/integration_itop/releases)
66
[![License](https://img.shields.io/badge/license-AGPL--3.0-green)](LICENSE)
77
[![Nextcloud](https://img.shields.io/badge/Nextcloud-30+-blue)](https://nextcloud.com)
88

@@ -17,7 +17,7 @@ A comprehensive Nextcloud integration that brings iTop IT Service Management and
1717
- 🔗 **Rich Previews** - Paste iTop links anywhere for interactive previews
1818
- 💬 **Smart Suggestions** - Get CI/ticket recommendations while typing in Talk or Text
1919
- 📊 **Dashboard Widgets** - Portal widget for personal tickets + Agent widget for operational metrics
20-
- 🔔 **Notifications** - Get alerted when tickets are assigned to you
20+
- 🔔 **Smart Notifications** - 12 notification types with weekend-aware SLA warnings (Portal + Agent tracks)
2121

2222
### **For IT Teams**
2323
- 🏗️ **CMDB Access** - Browse Configuration Items (PCs, phones, printers, software)
@@ -140,6 +140,32 @@ Quick access to tickets and CIs when creating documents or chatting.
140140
- **Power Users**: Full CMDB access within iTop ACL permissions
141141
- **Configurable**: Admins control which CI classes are searchable
142142

143+
### 🔔 Intelligent Notification System
144+
**NEW in v1.3.0** - Comprehensive notification system with 12 types across Portal and Agent tracks.
145+
146+
**Portal Notifications** (4 types for all users):
147+
- `ticket_status_changed` - Track ticket lifecycle from new to resolved
148+
- `ticket_resolved` - Resolution notifications
149+
- `agent_assigned` - When an agent is assigned to your ticket
150+
- `agent_responded` - New public comments from IT agents
151+
152+
**Agent Notifications** (8 types for IT staff):
153+
- `team_unassigned_new` - New unassigned tickets in your team's queue
154+
- `ticket_assigned` / `ticket_reassigned` - Ticket assignment changes
155+
- `ticket_tto_warning` / `ticket_ttr_warning` - SLA warnings with escalating urgency (⏰ 24h → ⚠️ 12h → 🟠 4h → 🔴 1h)
156+
- `ticket_sla_breach` - SLA deadline exceeded alerts
157+
- `ticket_priority_critical` - Critical priority escalations
158+
- `ticket_comment` - All comments on your tickets (public + private)
159+
160+
**Smart Features:**
161+
- **Weekend-Aware**: Friday uses 72h threshold, Saturday 48h to catch Monday/Tuesday breaches
162+
- **Zero Duplicates**: Crossing-time algorithm prevents repeated warnings for same SLA level
163+
- **Configurable Intervals**: Check frequency from 5-1440 minutes (default: 15 min)
164+
- **3-State Control**: Admin can set notifications as Disabled/Forced/User Choice
165+
- **Profile-Based**: Portal users see only portal notifications; agents get both tracks
166+
167+
See [docs/NOTIFICATIONS.md](docs/NOTIFICATIONS.md) for complete setup and troubleshooting guide.
168+
143169
### ⚙️ Personal Settings Dashboard
144170
Professional user configuration with real-time status monitoring.
145171

@@ -150,7 +176,8 @@ Professional user configuration with real-time status monitoring.
150176
- **User Profile**: See your iTop identity (name, email, organization, profiles)
151177
- **Ticket Counter**: Open incidents and user requests at a glance
152178
- **Secure Setup**: Token-based authentication with one-time personal token validation
153-
- **Feature Toggles**: Enable/disable search and notifications individually
179+
- **Feature Toggles**: Enable/disable search, portal notifications, and agent notifications individually
180+
- **Granular Control**: Per-notification-type toggles for User Choice notifications
154181
- **Clean Interface**: Professional theme-aware design
155182

156183
### 🛠️ Admin Configuration Panel
@@ -159,13 +186,18 @@ Comprehensive administration interface for system-wide configuration.
159186
![Admin Settings - Connection Status](docs/images/admin-settings1.png)
160187
![Admin Settings - Connection Configurations](docs/images/admin-settings2.png)
161188
![Admin Settings - Class Configurations](docs/images/admin-settings3.png)
162-
![Admin Settings - Cache Settings](docs/images/admin-settings4.png)
189+
![Admin Settings - Notification Configurations](docs/images/admin-settings4.png)
190+
![Admin Settings - Cache Settings](docs/images/admin-settings5.png)
163191
**Administrative Features:**
164192
- **Connection Management**: iTop URL, display name, application token (encrypted)
165193
- **CI Class Configuration**: Enable/disable CI classes with 3-state control:
166194
- **Disabled**: CI class hidden from all users
167195
- **Forced**: Enabled for all users (no opt-out)
168196
- **User Choice**: Enabled but users can opt-out in personal settings
197+
- **Notification Configuration**: Enable/disable Notifications with 3-state control:
198+
- **Disabled**: Notification is hidden from all users
199+
- **Forced**: Enabled for all users (no opt-out)
200+
- **User Choice**: Enabled but users can opt-out in personal settings
169201
- **Cache Performance Tuning**: Configurable TTLs for all cache types
170202
- CI Preview Cache: 10s-1h (default: 60s)
171203
- Ticket Info Cache: 10s-1h (default: 60s)
@@ -304,8 +336,11 @@ lib/
304336
├── Settings/
305337
│ ├── Admin.php # Admin configuration panel
306338
│ └── Personal.php # User settings interface
307-
└── Notification/
308-
└── Notifier.php # Notification system
339+
├── Notification/
340+
│ └── Notifier.php # Notification system (12 types)
341+
└── BackgroundJob/
342+
├── CheckPortalTicketUpdates.php # Portal notification processor
343+
└── CheckAgentTicketUpdates.php # Agent notification processor
309344
310345
src/
311346
└── views/
@@ -383,24 +418,36 @@ Adjust cache TTLs in **Admin Settings → Cache & Performance**:
383418

384419
---
385420

386-
## 📋 What's New in v1.2.0
421+
## 📋 What's New in v1.3.0
387422

388-
**Major New Feature: Dual Dashboard System** 🎉
423+
**Major New Feature: Intelligent Notification System** 🎉
389424

390425
### Added
391-
- **Portal Widget**: Personal ticket tracking for all users with status overview, recent ticket feed, and quick actions
392-
- **Agent Widget**: Comprehensive operational dashboard for IT agents with workload metrics, SLA tracking, and change management
393-
- **Profile-Based Display**: Automatic widget selection based on iTop user profiles (Portal vs Agent)
394-
- **Enhanced Ticket Display**: State-specific SVG icons, status/priority emojis, and rich hover details
395-
- **Dashboard Backend**: New API endpoints for SLA warnings, team queue, and change management
396-
- **Mobile Optimization**: Responsive design with adaptive layouts for all screen sizes
397-
- **Dashboard Caching**: Separate cache layer for dashboard data (default: 2min TTL)
426+
- **12 Notification Types**: 4 Portal + 8 Agent notification types for comprehensive ticket tracking
427+
- **Weekend-Aware SLA Warnings**: Friday uses 72h, Saturday 48h thresholds to prevent Monday breach surprises
428+
- **Crossing-Time Algorithm**: Zero duplicate warnings with smart threshold detection (24h/12h/4h/1h)
429+
- **Dual Background Jobs**: Independent Portal and Agent notification processors (5-min intervals)
430+
- **3-State Admin Control**: Configure each notification type as Disabled/Forced/User Choice
431+
- **Granular User Control**: Per-type toggles in personal settings with master enable/disable
432+
- **Team Queue Detection**: Agent notifications for new unassigned tickets in team queues
433+
- **SLA Breach Alerts**: Critical alerts when TTO/TTR deadlines exceeded
434+
- **Priority Escalation**: Automatic notifications when tickets reach critical priority
435+
- **OCC Testing**: Enhanced `itop:notifications:test-user` with --agent/--portal/--reset flags
436+
- **Comprehensive Documentation**: New [docs/NOTIFICATIONS.md](docs/NOTIFICATIONS.md) with setup, FAQ, and troubleshooting
398437

399438
### Changed
400-
- **Dashboard Performance**: Optimized OQL queries for faster dashboard loading
401-
- **Visual Hierarchy**: Improved status differentiation and metric indicators
402-
- **Error Handling**: Graceful fallback when API unavailable
403-
- **Translation Coverage**: Added 45 new strings for dashboard widgets in all supported languages
439+
- **Notification Display**: Escalating emoji icons based on urgency (⏰ → ⚠️ → 🟠 → 🔴 → 🚨)
440+
- **Personal Settings**: Agent notification section (only visible to non-portal users)
441+
- **Query Optimization**: Up to 100% API call reduction when notification types disabled
442+
- **Rate Limiting**: Max 20 notifications per user per run prevents notification spam
443+
- **Translation Coverage**: Added 16 new strings for agent notifications in all supported languages
444+
445+
### Previous Release: v1.2.0 - Dual Dashboard System
446+
447+
**Highlights:**
448+
- Portal Widget for personal ticket tracking
449+
- Agent Widget with SLA tracking and change management
450+
- Profile-based display with mobile optimization
404451

405452
### Previous Release: v1.1.0 - Configuration Item (CI) Browsing
406453

@@ -434,6 +481,12 @@ See [CHANGELOG.md](CHANGELOG.md) for complete details.
434481
- ✅ Verify search is enabled in personal settings
435482
- ✅ Check CI classes are enabled in admin settings
436483

484+
**Notifications not working**
485+
- ✅ Initialize background jobs after app installation (see [docs/NOTIFICATIONS.md](docs/NOTIFICATIONS.md))
486+
- ✅ Verify cron.php is running every 5 minutes
487+
- ✅ Check notification types are not disabled in admin settings
488+
- ✅ Ensure personal settings have notifications enabled
489+
437490
**Links not previewing**
438491
- ✅ Clear browser cache and Nextcloud cache
439492
- ✅ Verify URL matches iTop instance configured
@@ -473,14 +526,19 @@ curl -X POST https://itop.company.com/webservices/rest.php \
473526
- [x] Dual dashboard system (Portal + Agent widgets)
474527
- [x] SLA tracking and team metrics
475528

476-
### v1.3.0 (Next Release)
529+
### v1.3.0 (Released 2025-11-08) ✅
530+
- [x] Notification system with 12 types (Portal + Agent)
531+
- [x] Weekend-aware SLA warnings
532+
- [x] Background jobs for automated notification delivery
533+
534+
### v1.4.0 (Next Release)
477535
- [ ] Advanced search filters (date ranges, custom fields)
478-
- [ ] Notification system
536+
- [ ] Newsroom mirroring for broadcast notifications
479537

480538
### Future
481539
- [ ] Ticket creation from Nextcloud
482540
- [ ] CI relationship browser (dependencies, impacts)
483-
- [ ] Enhanced notification system with email digest
541+
- [ ] Email digest for notifications
484542
- [ ] Additional CI classes (Server, VirtualMachine, Network Device)
485543
- [ ] API rate limiting improvements
486544
- [ ] More languages (Spanish, Italian, Dutch, Portuguese)

appinfo/info.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,14 @@ Seamlessly connect your Nextcloud collaboration platform with iTop IT Service Ma
109109
</dependencies>
110110

111111
<background-jobs>
112-
<job>OCA\Itop\BackgroundJob\CheckOpenTickets</job>
112+
<job>OCA\Itop\BackgroundJob\CheckPortalTicketUpdates</job>
113+
<job>OCA\Itop\BackgroundJob\CheckAgentTicketUpdates</job>
113114
</background-jobs>
114115

116+
<commands>
117+
<command>OCA\Itop\Command\NotificationsTestUser</command>
118+
</commands>
119+
115120
<settings>
116121
<admin>OCA\Itop\Settings\Admin</admin>
117122
<admin-section>OCA\Itop\Settings\AdminSection</admin-section>

appinfo/routes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
['name' => 'config#setAdminConfig', 'url' => '/admin-config', 'verb' => 'PUT'],
1010
['name' => 'config#testAdminConnection', 'url' => '/admin-config/test', 'verb' => 'POST'],
1111
['name' => 'config#testApplicationToken', 'url' => '/admin-config/test-token', 'verb' => 'POST'],
12+
['name' => 'config#saveNotificationSettings', 'url' => '/notification-settings', 'verb' => 'POST'],
13+
['name' => 'config#saveNotificationConfig', 'url' => '/notification-config', 'verb' => 'POST'],
1214
['name' => 'config#saveCacheSettings', 'url' => '/cache-settings', 'verb' => 'POST'],
1315
['name' => 'config#clearAllCache', 'url' => '/clear-cache', 'verb' => 'POST'],
1416
['name' => 'config#saveCIClassConfig', 'url' => '/ci-class-config', 'verb' => 'POST'],

0 commit comments

Comments
 (0)