From caba9c5467fb66fb722d6ebc94190ed093fc9d6a Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Tue, 5 Jun 2018 17:19:15 +0200 Subject: Add notif dict docs --- docs/index.rst | 20 ++++++++++++++++++++ mastodon/Mastodon.py | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 4d7073c..56e0756 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -546,6 +546,26 @@ Push subscription dicts # if webpushes have been requested for those events. } +Push notification dicts +~~~~~~~~~~~~~~~~~~~~~~~ +.. _push notification dict: + +.. code-block:: python + + mastodon.push_subscription_decrypt_push(...) + # Returns the following dictionary + { + 'access_token': # Access token that can be used to access the API as the + # notified user + 'body': # Text body of the notification + 'icon': # URL to an icon for the notification + 'notification_id': # ID that can be passed to notification() to get the full + # notification object, + 'notification_type': # 'mention', 'reblog', 'follow' or 'favourite' + 'preferred_locale': # The users preferred locale + 'title': # Title for the notification + } + App registration and user authentication ---------------------------------------- Before you can use the mastodon API, you have to register your diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 38c9c75..dbf1ff2 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -132,6 +132,7 @@ class Mastodon: __DICT_VERSION_ACTIVITY = "2.1.2" __DICT_VERSION_REPORT = "1.1.0" __DICT_VERSION_PUSH = "2.4.0" + __DICT_VERSION_PUSH_NOTIF = "2.4.0" ### # Registering apps @@ -1609,13 +1610,14 @@ class Mastodon: return priv_dict, pub_dict + @api_version("2.4.0", "2.4.0", __DICT_VERSION_PUSH_NOTIF) def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header): """ Decrypts `data` received in a webpush request. Requires the private key dict from `push_subscription_generate_keys()`_ (`decrypt_params`) as well as the Encryption and server Crypto-Key headers from the received webpush - Returns the decoded webpush. + Returns the decoded webpush as a `push notification dict`_. """ salt = self.__decode_webpush_b64(encryption_header.split("salt=")[1].strip()) dhparams = self.__decode_webpush_b64(crypto_key_header.split("dh=")[1].split(";")[0].strip()) -- cgit v1.2.3