aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/hooks/wamail
blob: 192589b32634a10e6dc016e3ef199976a0b16e33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# wa-cli -> wamail hook: real-time delivery to the neomutt Maildir.
# Install: ln -s /path/to/wa-cli/contrib/hooks/wamail ~/.config/wa-cli/hooks/all.d/50-wamail
# The daemon runs hooks one at a time, in order; wamail has its own lock against the timer.
case "$1" in
    message_create|unread_count|chat_archived) ;;
    message_revoke_everyone)
        stanza=$(jq -r '.data.message.stanzaId // empty')
        [ -n "$stanza" ] && exec "$HOME/.local/bin/wamail" revoked "$WA_CLI_ACCOUNT" "$stanza"
        exit 0 ;;
    *) exit 0 ;;
esac
chat=$(jq -r '.data.chatId // .data.message.chatId // .data.chat.id // .data.id // empty')
case "$chat" in
    *@c.us|*@g.us|*@lid) exec "$HOME/.local/bin/wamail" sync "$WA_CLI_ACCOUNT" --chat "$chat" --quiet ;;
esac