mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-04-27 17:56:25 +02:00
Add Pushover notification support
- Add pushover_user_key and pushover_app_token columns to users table - Add sendPushoverNotification function to notifications service - Add Pushover test endpoint - Add Pushover settings UI in Settings page - User provides both User Key and App Token (self-hosted friendly) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3b7dce8bde
commit
3fa913814d
6 changed files with 208 additions and 5 deletions
|
|
@ -33,8 +33,10 @@ export default function Settings() {
|
|||
const [telegramBotToken, setTelegramBotToken] = useState('');
|
||||
const [telegramChatId, setTelegramChatId] = useState('');
|
||||
const [discordWebhookUrl, setDiscordWebhookUrl] = useState('');
|
||||
const [pushoverUserKey, setPushoverUserKey] = useState('');
|
||||
const [pushoverAppToken, setPushoverAppToken] = useState('');
|
||||
const [isSavingNotifications, setIsSavingNotifications] = useState(false);
|
||||
const [isTesting, setIsTesting] = useState<'telegram' | 'discord' | null>(null);
|
||||
const [isTesting, setIsTesting] = useState<'telegram' | 'discord' | 'pushover' | null>(null);
|
||||
|
||||
// AI state
|
||||
const [aiSettings, setAISettings] = useState<AISettings | null>(null);
|
||||
|
|
@ -216,6 +218,38 @@ export default function Settings() {
|
|||
}
|
||||
};
|
||||
|
||||
const handleSavePushover = async () => {
|
||||
clearMessages();
|
||||
setIsSavingNotifications(true);
|
||||
try {
|
||||
const response = await settingsApi.updateNotifications({
|
||||
pushover_user_key: pushoverUserKey || null,
|
||||
pushover_app_token: pushoverAppToken || null,
|
||||
});
|
||||
setNotificationSettings(response.data);
|
||||
setPushoverUserKey('');
|
||||
setPushoverAppToken('');
|
||||
setSuccess('Pushover settings saved successfully');
|
||||
} catch {
|
||||
setError('Failed to save Pushover settings');
|
||||
} finally {
|
||||
setIsSavingNotifications(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTestPushover = async () => {
|
||||
clearMessages();
|
||||
setIsTesting('pushover');
|
||||
try {
|
||||
await settingsApi.testPushover();
|
||||
setSuccess('Test notification sent to Pushover!');
|
||||
} catch {
|
||||
setError('Failed to send test notification');
|
||||
} finally {
|
||||
setIsTesting(null);
|
||||
}
|
||||
};
|
||||
|
||||
// AI handlers
|
||||
const handleSaveAI = async () => {
|
||||
clearMessages();
|
||||
|
|
@ -944,6 +978,61 @@ export default function Settings() {
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="settings-section">
|
||||
<div className="settings-section-header">
|
||||
<span className="settings-section-icon">🔔</span>
|
||||
<h2 className="settings-section-title">Pushover Notifications</h2>
|
||||
<span className={`settings-section-status ${notificationSettings?.pushover_configured ? 'configured' : 'not-configured'}`}>
|
||||
{notificationSettings?.pushover_configured ? 'Configured' : 'Not configured'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="settings-section-description">
|
||||
Receive price drop and back-in-stock alerts via Pushover. You'll need to create a Pushover account
|
||||
and an application to get your keys.
|
||||
</p>
|
||||
|
||||
<div className="settings-form-group">
|
||||
<label>User Key</label>
|
||||
<input
|
||||
type="password"
|
||||
value={pushoverUserKey}
|
||||
onChange={(e) => setPushoverUserKey(e.target.value)}
|
||||
placeholder={notificationSettings?.pushover_configured ? '••••••••••••••••' : 'Enter your user key'}
|
||||
/>
|
||||
<p className="hint">Find your User Key on the Pushover dashboard after logging in</p>
|
||||
</div>
|
||||
|
||||
<div className="settings-form-group">
|
||||
<label>Application API Token</label>
|
||||
<input
|
||||
type="password"
|
||||
value={pushoverAppToken}
|
||||
onChange={(e) => setPushoverAppToken(e.target.value)}
|
||||
placeholder={notificationSettings?.pushover_configured ? '••••••••••••••••' : 'Enter your app token'}
|
||||
/>
|
||||
<p className="hint">Create an application at pushover.net/apps to get an API token</p>
|
||||
</div>
|
||||
|
||||
<div className="settings-form-actions">
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={handleSavePushover}
|
||||
disabled={isSavingNotifications}
|
||||
>
|
||||
{isSavingNotifications ? 'Saving...' : 'Save Pushover Settings'}
|
||||
</button>
|
||||
{notificationSettings?.pushover_configured && (
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
onClick={handleTestPushover}
|
||||
disabled={isTesting === 'pushover'}
|
||||
>
|
||||
{isTesting === 'pushover' ? 'Sending...' : 'Send Test'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue