Skip to content

Commit 29615e2

Browse files
committed
Made jid optional on subscribe and rewrote with stanza builders
1 parent 5fd3c2b commit 29615e2

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

xmppcmd.bash

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,21 +574,22 @@ purge() {
574574
| send_stanza_iq set
575575
}
576576

577-
# subscribe <node> <jid>
577+
# subscribe <node> [jid]
578578
subscribe() {
579579
local node=$1
580-
local jid=$(qualify_jid $2)
580+
local jid=$(qualify_jid ${2-$xmpp_user})
581581

582582
# check args
583-
if (( $# < 2 )) || [[ "$1" =~ --help ]] || [[ "$1" =~ -h ]]; then
584-
echo "Usage: subscribe <node> <jid>"
583+
if (( $# < 1 )) || [[ "$1" =~ --help ]] || [[ "$1" =~ -h ]]; then
584+
echo "Usage: subscribe <node> [jid]"
585585
echo "Subscribe \"jid\" to the pubsub \"node\""
586586
return 0
587587
fi
588588

589-
echo "<subscribe node='$node' jid='$jid'/>" \
590-
| stanza_pubsub \
591-
| send_stanza_iq set
589+
eof \
590+
| stanza subscribe "node=$node" "jid=$jid" \
591+
| stanza_pubsub \
592+
| send_stanza_iq set
592593
}
593594

594595
# unsubscribe <node> <jid>

0 commit comments

Comments
 (0)