McKael / madonctl

CLI client for the Mastodon social network API
MIT License
193 stars 9 forks source link

Crash when using 'fromhtml' in notification template #13

Closed shellkr closed 6 years ago

shellkr commented 6 years ago

When I try this it will not show my notifications.

madonctl accounts notifications --list -o template --template '{{color "black,,bold"}}{{.created_at | tolocal | printf "%s\n"}}{{color "reset"}} {{color "yellow,,bold"}} {{.account.display_name}} {{color "reset"}} - {{.content | fromhtml}} {{"\n"}}'

If I remove the template it works. It will not crash when 'fromhtml' is removed but it will obviously not show the message either.

McKael commented 6 years ago

The "content" belongs to the "status" object. So it should be .status.content. For that not to fail when the notification is not a message, you might add a check... This seems to work for me:

madonctl accounts notifications --list -o template --template \
    '{{color "black,,bold"}}{{.created_at | tolocal | printf "%s\n"}}{{color "reset"}} {{color "yellow,,bold"}} {{.account.display_name}} {{color "reset"}} - {{if .status}}{{.status.content | fromhtml}}{{end}}{{"\n"}}'

Does that answer your question? Mikael

shellkr commented 6 years ago

Yes, it did! Thanks! ...but in other cases like the timeline it is not needed. I didn't try the notification.tmpl template in the repo but it might need an update. It is also missing the .status.content.