Skip to content

Commit 58c4398

Browse files
committed
Fixed get_subscriptions and get_subscribers to be more clear and use new stanza builders
1 parent d814a32 commit 58c4398

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

xmppcmd.bash

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,29 @@ get_nodes() {
620620
| send_stanza_iq get
621621
}
622622

623-
# get_subscriptions
623+
# Get your subscription list OR subscriptions with a certain node
624+
# get_subscriptions [node]
624625
get_subscriptions() {
625626
local node=$1
626627

627628
# check args
628629
if (( $# < 0 )) || [[ "$1" =~ --help ]] || [[ "$1" =~ -h ]]; then
629-
echo "Usage: get_subscriptions"
630+
echo "Usage: get_subscriptions [node]"
631+
echo "Get your subscription list OR subscriptions with a certain node"
630632
return 0
631633
fi
632634

633-
echo "<subscriptions node='$node'/>" \
635+
if [ -n "$node" ]; then
636+
eof \
637+
| stanza subscriptions "node=$node" \
638+
| stanza_pubsub \
639+
| send_stanza_iq get
640+
else
641+
eof \
642+
| stanza subscriptions \
634643
| stanza_pubsub \
635644
| send_stanza_iq get
645+
fi
636646
}
637647

638648
# Get a list of subscribers of a node
@@ -642,14 +652,16 @@ get_subscribers() {
642652

643653
# check args
644654
if (( $# < 1 )) || [[ "$1" =~ --help ]] || [[ "$1" =~ -h ]]; then
645-
echo "Usage: get_subscribers <node>" >&2
646-
echo "Get a list of subscribers of a given node" >&2
655+
echo "Usage: get_subscribers <node>"
656+
echo "Get a list of subscribers of a given node"
657+
echo "You must be owner of the node"
647658
return 0
648659
fi
649660

650-
echo "<subscriptions node='$node'/>" \
651-
| stanza_pubsub owner \
652-
| send_stanza_iq get
661+
eof \
662+
| stanza subscriptions "node=$node" \
663+
| stanza_pubsub owner \
664+
| send_stanza_iq get
653665
}
654666

655667
# Set subscribers for a given node

0 commit comments

Comments
 (0)