|
| 1 | +# Feature Request: Apprise Notification Support |
| 2 | + |
| 3 | +## Overview |
| 4 | +Add optional Apprise notification support to send real-time alerts when new moderation actions are processed and added to the database. |
| 5 | + |
| 6 | +## Motivation |
| 7 | +- **Real-time awareness**: Moderators get immediate notifications of new actions |
| 8 | +- **Multi-platform support**: Apprise supports 80+ notification services (Discord, Slack, Email, etc.) |
| 9 | +- **Flexible configuration**: Each subreddit can have different notification preferences |
| 10 | +- **Action filtering**: Only notify for specific action types or moderators |
| 11 | + |
| 12 | +## Proposed Implementation |
| 13 | + |
| 14 | +### 1. Configuration Options |
| 15 | +Add new configuration fields: |
| 16 | +```json |
| 17 | +{ |
| 18 | + "notifications": { |
| 19 | + "enabled": false, |
| 20 | + "apprise_urls": [ |
| 21 | + "discord://webhook_id/webhook_token", |
| 22 | + "mailto://user:password@domain.com" |
| 23 | + ], |
| 24 | + "notify_actions": ["removelink", "removecomment", "spamlink", "spamcomment"], |
| 25 | + "ignore_moderators": ["AutoModerator"], |
| 26 | + "rate_limit": { |
| 27 | + "max_per_minute": 10, |
| 28 | + "burst_limit": 5 |
| 29 | + } |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### 2. Environment Variable Support |
| 35 | +- `APPRISE_ENABLED`: Enable/disable notifications |
| 36 | +- `APPRISE_URLS`: Comma-separated notification URLs |
| 37 | +- `NOTIFY_ACTIONS`: Comma-separated action types to notify |
| 38 | +- `NOTIFY_RATE_LIMIT`: Rate limiting configuration |
| 39 | + |
| 40 | +### 3. Notification Content |
| 41 | +**Subject**: `[{subreddit}] Moderation Action: {action_type}` |
| 42 | + |
| 43 | +**Body**: |
| 44 | +``` |
| 45 | +Action: {action_type} |
| 46 | +Moderator: {moderator_name} |
| 47 | +Target: {target_author} |
| 48 | +Content: {content_title} |
| 49 | +Reason: {removal_reason} |
| 50 | +Link: {content_url} |
| 51 | +Time: {timestamp} |
| 52 | +``` |
| 53 | + |
| 54 | +### 4. Features |
| 55 | +- **Rate limiting**: Prevent notification spam |
| 56 | +- **Retry logic**: Handle temporary service outages |
| 57 | +- **Async notifications**: Don't block main processing |
| 58 | +- **Error handling**: Graceful degradation if notifications fail |
| 59 | +- **Testing**: `--test-notifications` flag to verify configuration |
| 60 | + |
| 61 | +### 5. Integration Points |
| 62 | +- **After action processing**: Send notification when new action is stored in database |
| 63 | +- **Batch notifications**: Optional digest mode for high-volume subreddits |
| 64 | +- **Filtering**: Skip notifications for ignored moderators or action types |
| 65 | + |
| 66 | +## Technical Requirements |
| 67 | + |
| 68 | +### Dependencies |
| 69 | +- Add `apprise` to requirements.txt |
| 70 | +- Optional dependency with graceful fallback if not installed |
| 71 | + |
| 72 | +### Database Schema |
| 73 | +Consider adding notification tracking table: |
| 74 | +```sql |
| 75 | +CREATE TABLE notification_log ( |
| 76 | + id INTEGER PRIMARY KEY, |
| 77 | + action_id TEXT, |
| 78 | + subreddit TEXT, |
| 79 | + notification_urls TEXT, |
| 80 | + status TEXT, -- 'sent', 'failed', 'skipped' |
| 81 | + created_at INTEGER, |
| 82 | + error_message TEXT |
| 83 | +); |
| 84 | +``` |
| 85 | + |
| 86 | +### Configuration Validation |
| 87 | +- Validate Apprise URLs on startup |
| 88 | +- Test notification connectivity with `--test` flag |
| 89 | +- Clear error messages for invalid configurations |
| 90 | + |
| 91 | +## Example Usage |
| 92 | + |
| 93 | +### Basic Setup |
| 94 | +```bash |
| 95 | +# Environment variables |
| 96 | +export APPRISE_ENABLED=true |
| 97 | +export APPRISE_URLS="discord://webhook_id/webhook_token" |
| 98 | +export NOTIFY_ACTIONS="removelink,removecomment" |
| 99 | + |
| 100 | +# Run with notifications |
| 101 | +python modlog_wiki_publisher.py --source-subreddit usenet --continuous |
| 102 | +``` |
| 103 | + |
| 104 | +### Docker Deployment |
| 105 | +```yaml |
| 106 | +environment: |
| 107 | + - APPRISE_ENABLED=true |
| 108 | + - APPRISE_URLS=discord://webhook_id/webhook_token,slack://token/channel |
| 109 | + - NOTIFY_ACTIONS=removelink,removecomment,spamlink,spamcomment |
| 110 | + - NOTIFY_RATE_LIMIT=10 |
| 111 | +``` |
| 112 | +
|
| 113 | +## Security Considerations |
| 114 | +- Store notification URLs securely (environment variables recommended) |
| 115 | +- Rate limiting to prevent abuse |
| 116 | +- Option to anonymize moderator names in notifications |
| 117 | +- Validate notification URLs to prevent injection attacks |
| 118 | +
|
| 119 | +## Testing Strategy |
| 120 | +- Unit tests for notification formatting and rate limiting |
| 121 | +- Integration tests with mock Apprise services |
| 122 | +- `--test-notifications` flag to verify configuration |
| 123 | +- Documentation with example configurations for popular services |
| 124 | + |
| 125 | +## Documentation Updates |
| 126 | +- Add notification configuration section to CLAUDE.md |
| 127 | +- Update README.md with notification examples |
| 128 | +- Add troubleshooting guide for common notification issues |
| 129 | +- Document supported Apprise URL formats |
| 130 | + |
| 131 | +## Breaking Changes |
| 132 | +None - this is an optional feature that defaults to disabled. |
| 133 | + |
| 134 | +## Future Enhancements |
| 135 | +- Web dashboard for notification management |
| 136 | +- Custom notification templates |
| 137 | +- Notification scheduling (e.g., daily digest) |
| 138 | +- Integration with Reddit's real-time API for instant notifications |
| 139 | + |
| 140 | +--- |
| 141 | + |
| 142 | +**Priority**: Medium |
| 143 | +**Complexity**: Medium |
| 144 | +**Estimated effort**: 1-2 days development + testing |
| 145 | +**Dependencies**: None (Apprise is optional) |
0 commit comments