diff options
author | Lorenz Diener <[email protected]> | 2018-06-05 17:19:15 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2018-06-05 17:19:15 +0200 |
commit | caba9c5467fb66fb722d6ebc94190ed093fc9d6a (patch) | |
tree | 53e8805a3d690c56a86876d3c6181ebf7cb7fb28 | |
parent | 4b747886b918d3da91f62b2ba7f7bc4aa142cf79 (diff) | |
download | mastodon.py-caba9c5467fb66fb722d6ebc94190ed093fc9d6a.tar.gz |
Add notif dict docs
-rw-r--r-- | docs/index.rst | 20 | ||||
-rw-r--r-- | mastodon/Mastodon.py | 4 |
2 files changed, 23 insertions, 1 deletions
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 | |||
546 | # if webpushes have been requested for those events. | 546 | # if webpushes have been requested for those events. |
547 | } | 547 | } |
548 | 548 | ||
549 | Push notification dicts | ||
550 | ~~~~~~~~~~~~~~~~~~~~~~~ | ||
551 | .. _push notification dict: | ||
552 | |||
553 | .. code-block:: python | ||
554 | |||
555 | mastodon.push_subscription_decrypt_push(...) | ||
556 | # Returns the following dictionary | ||
557 | { | ||
558 | 'access_token': # Access token that can be used to access the API as the | ||
559 | # notified user | ||
560 | 'body': # Text body of the notification | ||
561 | 'icon': # URL to an icon for the notification | ||
562 | 'notification_id': # ID that can be passed to notification() to get the full | ||
563 | # notification object, | ||
564 | 'notification_type': # 'mention', 'reblog', 'follow' or 'favourite' | ||
565 | 'preferred_locale': # The users preferred locale | ||
566 | 'title': # Title for the notification | ||
567 | } | ||
568 | |||
549 | App registration and user authentication | 569 | App registration and user authentication |
550 | ---------------------------------------- | 570 | ---------------------------------------- |
551 | Before you can use the mastodon API, you have to register your | 571 | 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: | |||
132 | __DICT_VERSION_ACTIVITY = "2.1.2" | 132 | __DICT_VERSION_ACTIVITY = "2.1.2" |
133 | __DICT_VERSION_REPORT = "1.1.0" | 133 | __DICT_VERSION_REPORT = "1.1.0" |
134 | __DICT_VERSION_PUSH = "2.4.0" | 134 | __DICT_VERSION_PUSH = "2.4.0" |
135 | __DICT_VERSION_PUSH_NOTIF = "2.4.0" | ||
135 | 136 | ||
136 | ### | 137 | ### |
137 | # Registering apps | 138 | # Registering apps |
@@ -1609,13 +1610,14 @@ class Mastodon: | |||
1609 | 1610 | ||
1610 | return priv_dict, pub_dict | 1611 | return priv_dict, pub_dict |
1611 | 1612 | ||
1613 | @api_version("2.4.0", "2.4.0", __DICT_VERSION_PUSH_NOTIF) | ||
1612 | def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header): | 1614 | def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header): |
1613 | """ | 1615 | """ |
1614 | Decrypts `data` received in a webpush request. Requires the private key dict | 1616 | Decrypts `data` received in a webpush request. Requires the private key dict |
1615 | from `push_subscription_generate_keys()`_ (`decrypt_params`) as well as the | 1617 | from `push_subscription_generate_keys()`_ (`decrypt_params`) as well as the |
1616 | Encryption and server Crypto-Key headers from the received webpush | 1618 | Encryption and server Crypto-Key headers from the received webpush |
1617 | 1619 | ||
1618 | Returns the decoded webpush. | 1620 | Returns the decoded webpush as a `push notification dict`_. |
1619 | """ | 1621 | """ |
1620 | salt = self.__decode_webpush_b64(encryption_header.split("salt=")[1].strip()) | 1622 | salt = self.__decode_webpush_b64(encryption_header.split("salt=")[1].strip()) |
1621 | dhparams = self.__decode_webpush_b64(crypto_key_header.split("dh=")[1].split(";")[0].strip()) | 1623 | dhparams = self.__decode_webpush_b64(crypto_key_header.split("dh=")[1].split(";")[0].strip()) |