binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
17.64k stars 684 forks source link

Any possibility of reading a topic via ntfy cli from the past? #925

Closed K0-RR closed 10 months ago

K0-RR commented 10 months ago

Both Android and web app allow for reading notifications sent BEFORE subscribing to the topic. This doesn't seem to be the case for the Linux app.

wunter8 commented 10 months ago

Are you talking about the ntfy sub CLI tool? If so, use the since flag. For example, you can do ntfy sub --since all topic to get the messages in the cache for that topic. The shorthand ntfy sub -s all topic also works. See ntfy sub help for more info

K0-RR commented 10 months ago

Yes, -s all did the trick, thanks. The next problem appears - is there any way to convert the unix timestamp into a human-readable time format without using external tools? I suggest making it print both unix and regular time.

wunter8 commented 10 months ago

Not right now, no. You could use jq to parse the JSON and change the value, but I recognize that's an external tool

K0-RR commented 10 months ago

Ok, at least jq seems to be installed by default on my OS. For anyone wondering, the command I used is ntfy sub -s all topic_name | jq '.time |= strflocaltime("%Y-%m-%d %H:%M:%S")'