Automatic Replies to Subscription Requests

Automatic Replies to Subscription Requests

To automate the subscription approval you will need a rule that selects on wrangler inbound_pending_subscription_added event which raises a wrangler pending_subscription_approval event with channel_name attribute set to the channel_name of the inbound_pending_subscription_added event, this can be done by passing the attributes along.

rule autoAccept { select when wrangler inbound_pending_subscription_added pre{ attributes = event:attrs().klog("subcription :"); } always{ raise wrangler event "pending_subscription_approval" attributes attributes; log info "auto accepted subcription."; } }

Security Issues

 The preceding code shows a simple example of approving subscriptions automatically. This code, installed in a pico, would automatically subscribe to every pico that requests it.

Production code should be more circumspect about what subscriptions it accepts. For example, a pico might automatically accept any subscription request from its parent. Or any subscription request that contains a specific password.

Copyright Picolabs | Licensed under Creative Commons.