aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 6e5bc29..12a054a 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -2756,7 +2756,7 @@ class Mastodon:
2756 def push_subscription_set(self, endpoint, encrypt_params, follow_events=None, 2756 def push_subscription_set(self, endpoint, encrypt_params, follow_events=None,
2757 favourite_events=None, reblog_events=None, 2757 favourite_events=None, reblog_events=None,
2758 mention_events=None, poll_events=None, 2758 mention_events=None, poll_events=None,
2759 follow_request_events=None): 2759 follow_request_events=None, status_events=None, policy='all'):
2760 """ 2760 """
2761 Sets up or modifies the push subscription the logged-in user has for this app. 2761 Sets up or modifies the push subscription the logged-in user has for this app.
2762 2762
@@ -2766,10 +2766,16 @@ class Mastodon:
2766 You can generate this as well as the corresponding private key using the 2766 You can generate this as well as the corresponding private key using the
2767 `push_subscription_generate_keys()`_ function. 2767 `push_subscription_generate_keys()`_ function.
2768 2768
2769 `policy` controls what sources will generate webpush events. Valid values are
2770 `all`, `none`, `follower` and `followed`.
2771
2769 The rest of the parameters controls what kind of events you wish to subscribe to. 2772 The rest of the parameters controls what kind of events you wish to subscribe to.
2770 2773
2771 Returns a `push subscription dict`_. 2774 Returns a `push subscription dict`_.
2772 """ 2775 """
2776 if not policy in ['all', 'none', 'follower', 'followed']:
2777 raise MastodonIllegalArgumentError("Valid values for policy are 'all', 'none', 'follower' or 'followed'.")
2778
2773 endpoint = Mastodon.__protocolize(endpoint) 2779 endpoint = Mastodon.__protocolize(endpoint)
2774 2780
2775 push_pubkey_b64 = base64.b64encode(encrypt_params['pubkey']) 2781 push_pubkey_b64 = base64.b64encode(encrypt_params['pubkey'])
@@ -2778,7 +2784,8 @@ class Mastodon:
2778 params = { 2784 params = {
2779 'subscription[endpoint]': endpoint, 2785 'subscription[endpoint]': endpoint,
2780 'subscription[keys][p256dh]': push_pubkey_b64, 2786 'subscription[keys][p256dh]': push_pubkey_b64,
2781 'subscription[keys][auth]': push_auth_b64 2787 'subscription[keys][auth]': push_auth_b64,
2788 'policy': policy
2782 } 2789 }
2783 2790
2784 if follow_events != None: 2791 if follow_events != None:
@@ -2799,6 +2806,9 @@ class Mastodon:
2799 if follow_request_events != None: 2806 if follow_request_events != None:
2800 params['data[alerts][follow_request]'] = follow_request_events 2807 params['data[alerts][follow_request]'] = follow_request_events
2801 2808
2809 if follow_request_events != None:
2810 params['data[alerts][status]'] = status_events
2811
2802 # Canonicalize booleans 2812 # Canonicalize booleans
2803 params = self.__generate_params(params) 2813 params = self.__generate_params(params)
2804 2814
Powered by cgit v1.2.3 (git 2.41.0)