mirror of
https://github.com/sune-org/us.proxy.sune.chat.git
synced 2026-03-17 02:21:01 +00:00
Feat: Include duration in ntfy notifications
This commit is contained in:
6
run.js
6
run.js
@@ -114,16 +114,18 @@ function stop(r) {
|
|||||||
flush(r, true)
|
flush(r, true)
|
||||||
r.phase = 'done'
|
r.phase = 'done'
|
||||||
r.error = null
|
r.error = null
|
||||||
|
const duration = ((Date.now() - r.startedAt) / 1000).toFixed(1)
|
||||||
try { r.controller?.abort() } catch {}
|
try { r.controller?.abort() } catch {}
|
||||||
saveSnapshot(r)
|
saveSnapshot(r)
|
||||||
bcast(r, { type: 'done' })
|
bcast(r, { type: 'done' })
|
||||||
notify(`Run ${r.rid} ended.`, 3, ['stop_sign'])
|
notify(`Run ${r.rid} ended. Duration: ${duration}s`, 3, ['stop_sign'])
|
||||||
}
|
}
|
||||||
|
|
||||||
function fail(r, message) {
|
function fail(r, message) {
|
||||||
if (r.phase !== 'running') return
|
if (r.phase !== 'running') return
|
||||||
clearTimeoutTimer(r)
|
clearTimeoutTimer(r)
|
||||||
const err = String(message || 'stream_failed')
|
const err = String(message || 'stream_failed')
|
||||||
|
const duration = ((Date.now() - r.startedAt) / 1000).toFixed(1)
|
||||||
queueDelta(r, `\n\nRun failed: ${err}`)
|
queueDelta(r, `\n\nRun failed: ${err}`)
|
||||||
flush(r, true)
|
flush(r, true)
|
||||||
r.phase = 'error'
|
r.phase = 'error'
|
||||||
@@ -131,7 +133,7 @@ function fail(r, message) {
|
|||||||
try { r.controller?.abort() } catch {}
|
try { r.controller?.abort() } catch {}
|
||||||
saveSnapshot(r)
|
saveSnapshot(r)
|
||||||
bcast(r, { type: 'err', message: r.error })
|
bcast(r, { type: 'err', message: r.error })
|
||||||
notify(`Run ${r.rid} failed: ${r.error}`, 3, ['rotating_light'])
|
notify(`Run ${r.rid} failed after ${duration}s: ${r.error}`, 3, ['rotating_light'])
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeMessages(messages) {
|
function sanitizeMessages(messages) {
|
||||||
|
|||||||
Reference in New Issue
Block a user