aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-13 12:27:06 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-13 12:27:06 +0200
commit95ae148f45210f73f2c3e951ec3cc33531a239fe (patch)
treea842ef59b8b5dfee9e1b7e00515940c6d8bb0fc8 /mastodon
parent0bc2963419833cfeeb4fe2aceba63ee1239cabb5 (diff)
downloadmastodon.py-95ae148f45210f73f2c3e951ec3cc33531a239fe.tar.gz
add remote parameter, filtering by date for masto mainline
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py215
1 files changed, 89 insertions, 126 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 5cc0f57..08a91a0 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -210,9 +210,8 @@ class Mastodon:
210 __DICT_VERSION_MEDIA = "2.8.2" 210 __DICT_VERSION_MEDIA = "2.8.2"
211 __DICT_VERSION_ACCOUNT = "3.1.0" 211 __DICT_VERSION_ACCOUNT = "3.1.0"
212 __DICT_VERSION_POLL = "2.8.0" 212 __DICT_VERSION_POLL = "2.8.0"
213 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version(bigger_version("3.1.0", 213 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version(bigger_version("3.1.0", __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION), __DICT_VERSION_POLL)
214 __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION), __DICT_VERSION_POLL) 214 __DICT_VERSION_INSTANCE = bigger_version("3.1.4", __DICT_VERSION_ACCOUNT)
215 __DICT_VERSION_INSTANCE = bigger_version("2.9.2", __DICT_VERSION_ACCOUNT)
216 __DICT_VERSION_HASHTAG = "2.3.4" 215 __DICT_VERSION_HASHTAG = "2.3.4"
217 __DICT_VERSION_EMOJI = "3.0.0" 216 __DICT_VERSION_EMOJI = "3.0.0"
218 __DICT_VERSION_RELATIONSHIP = "2.5.0" 217 __DICT_VERSION_RELATIONSHIP = "2.5.0"
@@ -220,8 +219,7 @@ class Mastodon:
220 __DICT_VERSION_CONTEXT = bigger_version("1.0.0", __DICT_VERSION_STATUS) 219 __DICT_VERSION_CONTEXT = bigger_version("1.0.0", __DICT_VERSION_STATUS)
221 __DICT_VERSION_LIST = "2.1.0" 220 __DICT_VERSION_LIST = "2.1.0"
222 __DICT_VERSION_CARD = "2.0.0" 221 __DICT_VERSION_CARD = "2.0.0"
223 __DICT_VERSION_SEARCHRESULT = bigger_version(bigger_version(bigger_version("1.0.0", 222 __DICT_VERSION_SEARCHRESULT = bigger_version(bigger_version(bigger_version("1.0.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS), __DICT_VERSION_HASHTAG)
224 __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS), __DICT_VERSION_HASHTAG)
225 __DICT_VERSION_ACTIVITY = "2.1.2" 223 __DICT_VERSION_ACTIVITY = "2.1.2"
226 __DICT_VERSION_REPORT = "2.9.1" 224 __DICT_VERSION_REPORT = "2.9.1"
227 __DICT_VERSION_PUSH = "2.4.0" 225 __DICT_VERSION_PUSH = "2.4.0"
@@ -735,32 +733,41 @@ class Mastodon:
735 ### 733 ###
736 # Reading data: Timelines 734 # Reading data: Timelines
737 ## 735 ##
738 @api_version("1.0.0", "2.6.0", __DICT_VERSION_STATUS) 736 @api_version("1.0.0", "3.1.4", __DICT_VERSION_STATUS)
739 def timeline(self, timeline="home", max_id=None, min_id=None, since_id=None, limit=None): 737 def timeline(self, timeline="home", max_id=None, min_id=None, since_id=None, limit=None, only_media=False, local=False, remote=False):
740 """ 738 """
741 Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', 739 Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public',
742 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do. 740 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do.
743 Local hashtag timelines are supported via the `timeline_hashtag()`_ function.
744 741
745 The default timeline is the "home" timeline. 742 The default timeline is the "home" timeline.
746 743
747 Media only queries are supported via the `timeline_public()`_ and `timeline_hashtag()`_ functions. 744 Specify `only_media` to only get posts with attached media. Specify `local` to only get local statuses,
745 and `remote` to only get remote statuses. Some options are mutually incompatible as dictated by logic.
748 746
749 May or may not require authentication depending on server settings and what is specifically requested. 747 May or may not require authentication depending on server settings and what is specifically requested.
750 748
751 Returns a list of `toot dicts`_. 749 Returns a list of `toot dicts`_.
752 """ 750 """
753 if max_id != None: 751 if max_id != None:
754 max_id = self.__unpack_id(max_id) 752 max_id = self.__unpack_id(max_id, dateconv=True)
755 753
756 if min_id != None: 754 if min_id != None:
757 min_id = self.__unpack_id(min_id) 755 min_id = self.__unpack_id(min_id, dateconv=True)
758 756
759 if since_id != None: 757 if since_id != None:
760 since_id = self.__unpack_id(since_id) 758 since_id = self.__unpack_id(since_id, dateconv=True)
761 759
762 params_initial = locals() 760 params_initial = locals()
763 761
762 if local == False:
763 del params_initial['local']
764
765 if remote == False:
766 del params_initial['remote']
767
768 if only_media == False:
769 del params_initial['only_media']
770
764 if timeline == "local": 771 if timeline == "local":
765 timeline = "public" 772 timeline = "public"
766 params_initial['local'] = True 773 params_initial['local'] = True
@@ -769,100 +776,54 @@ class Mastodon:
769 url = '/api/v1/timelines/{0}'.format(timeline) 776 url = '/api/v1/timelines/{0}'.format(timeline)
770 return self.__api_request('GET', url, params) 777 return self.__api_request('GET', url, params)
771 778
772 @api_version("1.0.0", "2.6.0", __DICT_VERSION_STATUS) 779 @api_version("1.0.0", "3.1.4", __DICT_VERSION_STATUS)
773 def timeline_home(self, max_id=None, min_id=None, since_id=None, limit=None): 780 def timeline_home(self, max_id=None, min_id=None, since_id=None, limit=None, only_media=False, local=False, remote=False):
774 """ 781 """
775 Fetch the logged-in users home timeline (i.e. followed users and self). 782 Convenience method: Fetches the logged-in users home timeline (i.e. followed users and self). Params as in `timeline()`.
776 783
777 Returns a list of `toot dicts`_. 784 Returns a list of `toot dicts`_.
778 """ 785 """
779 return self.timeline('home', max_id=max_id, min_id=min_id, 786 return self.timeline('home', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
780 since_id=since_id, limit=limit)
781 787
782 @api_version("1.0.0", "2.6.0", __DICT_VERSION_STATUS) 788 @api_version("1.0.0", "3.1.4", __DICT_VERSION_STATUS)
783 def timeline_local(self, max_id=None, min_id=None, since_id=None, limit=None): 789 def timeline_local(self, max_id=None, min_id=None, since_id=None, limit=None, only_media=False):
784 """ 790 """
785 Fetches the local / instance-wide timeline, not including replies. 791 Convenience method: Fetches the local / instance-wide timeline, not including replies. Params as in `timeline()`.
786 792
787 Returns a list of `toot dicts`_. 793 Returns a list of `toot dicts`_.
788 """ 794 """
789 return self.timeline('local', max_id=max_id, min_id=min_id, 795 return self.timeline('local', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media)
790 since_id=since_id, limit=limit)
791 796
792 @api_version("1.0.0", "2.6.0", __DICT_VERSION_STATUS) 797 @api_version("1.0.0", "3.1.4", __DICT_VERSION_STATUS)
793 def timeline_public(self, max_id=None, min_id=None, since_id=None, limit=None, only_media=False): 798 def timeline_public(self, max_id=None, min_id=None, since_id=None, limit=None, only_media=False, local=False, remote=False):
794 """ 799 """
795 Fetches the public / visible-network timeline, not including replies. 800 Convenience method: Fetches the public / visible-network / federated timeline, not including replies. Params as in `timeline()`.
796
797 Set `only_media` to True to retrieve only statuses with media attachments.
798 801
799 Returns a list of `toot dicts`_. 802 Returns a list of `toot dicts`_.
800 """ 803 """
801 if max_id != None: 804 return self.timeline('public', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
802 max_id = self.__unpack_id(max_id)
803
804 if min_id != None:
805 min_id = self.__unpack_id(min_id)
806 805
807 if since_id != None: 806 @api_version("1.0.0", "3.1.4", __DICT_VERSION_STATUS)
808 since_id = self.__unpack_id(since_id) 807 def timeline_hashtag(self, hashtag, local=False, max_id=None, min_id=None, since_id=None, limit=None, only_media=False, remote=False):
809
810 params_initial = locals()
811
812 if only_media == False:
813 del params_initial['only_media']
814
815 url = '/api/v1/timelines/public'
816 params = self.__generate_params(params_initial)
817
818 return self.__api_request('GET', url, params)
819
820 @api_version("1.0.0", "2.6.0", __DICT_VERSION_STATUS)
821 def timeline_hashtag(self, hashtag, local=False, max_id=None, min_id=None, since_id=None, limit=None, only_media=False):
822 """ 808 """
823 Fetch a timeline of toots with a given hashtag. The hashtag parameter 809 Convenience method: Fetch a timeline of toots with a given hashtag. The hashtag parameter
824 should not contain the leading #. 810 should not contain the leading #. Params as in `timeline()`.
825
826 Set `local` to True to retrieve only instance-local tagged posts.
827 Set `only_media` to True to retrieve only statuses with media attachments.
828 811
829 Returns a list of `toot dicts`_. 812 Returns a list of `toot dicts`_.
830 """ 813 """
831 if hashtag.startswith("#"): 814 if hashtag.startswith("#"):
832 raise MastodonIllegalArgumentError("Hashtag parameter should omit leading #") 815 raise MastodonIllegalArgumentError("Hashtag parameter should omit leading #")
833 816 return self.timeline('tag/{0}'.format(hashtag), max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
834 if max_id != None:
835 max_id = self.__unpack_id(max_id)
836
837 if min_id != None:
838 min_id = self.__unpack_id(min_id)
839
840 if since_id != None:
841 since_id = self.__unpack_id(since_id)
842
843 params_initial = locals()
844
845 if local == False:
846 del params_initial['local']
847
848 if only_media == False:
849 del params_initial['only_media']
850
851 url = '/api/v1/timelines/tag/{0}'.format(hashtag)
852 params = self.__generate_params(params_initial, ['hashtag'])
853
854 return self.__api_request('GET', url, params)
855 817
856 @api_version("2.1.0", "2.6.0", __DICT_VERSION_STATUS) 818 @api_version("2.1.0", "3.1.4", __DICT_VERSION_STATUS)
857 def timeline_list(self, id, max_id=None, min_id=None, since_id=None, limit=None): 819 def timeline_list(self, id, max_id=None, min_id=None, since_id=None, limit=None, only_media=False, local=False, remote=False):
858 """ 820 """
859 Fetches a timeline containing all the toots by users in a given list. 821 Convenience method: Fetches a timeline containing all the toots by users in a given list. Params as in `timeline()`.
860 822
861 Returns a list of `toot dicts`_. 823 Returns a list of `toot dicts`_.
862 """ 824 """
863 id = self.__unpack_id(id) 825 id = self.__unpack_id(id)
864 return self.timeline('list/{0}'.format(id), max_id=max_id, 826 return self.timeline('list/{0}'.format(id), max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
865 min_id=min_id, since_id=since_id, limit=limit)
866 827
867 @api_version("2.6.0", "2.6.0", __DICT_VERSION_CONVERSATION) 828 @api_version("2.6.0", "2.6.0", __DICT_VERSION_CONVERSATION)
868 def conversations(self, max_id=None, min_id=None, since_id=None, limit=None): 829 def conversations(self, max_id=None, min_id=None, since_id=None, limit=None):
@@ -872,13 +833,13 @@ class Mastodon:
872 Returns a list of `conversation dicts`_. 833 Returns a list of `conversation dicts`_.
873 """ 834 """
874 if max_id != None: 835 if max_id != None:
875 max_id = self.__unpack_id(max_id) 836 max_id = self.__unpack_id(max_id, dateconv=True)
876 837
877 if min_id != None: 838 if min_id != None:
878 min_id = self.__unpack_id(min_id) 839 min_id = self.__unpack_id(min_id, dateconv=True)
879 840
880 if since_id != None: 841 if since_id != None:
881 since_id = self.__unpack_id(since_id) 842 since_id = self.__unpack_id(since_id, dateconv=True)
882 843
883 params = self.__generate_params(locals()) 844 params = self.__generate_params(locals())
884 return self.__api_request('GET', "/api/v1/conversations/", params) 845 return self.__api_request('GET', "/api/v1/conversations/", params)
@@ -1023,13 +984,13 @@ class Mastodon:
1023 del mentions_only 984 del mentions_only
1024 985
1025 if max_id != None: 986 if max_id != None:
1026 max_id = self.__unpack_id(max_id) 987 max_id = self.__unpack_id(max_id, dateconv=True)
1027 988
1028 if min_id != None: 989 if min_id != None:
1029 min_id = self.__unpack_id(min_id) 990 min_id = self.__unpack_id(min_id, dateconv=True)
1030 991
1031 if since_id != None: 992 if since_id != None:
1032 since_id = self.__unpack_id(since_id) 993 since_id = self.__unpack_id(since_id, dateconv=True)
1033 994
1034 if account_id != None: 995 if account_id != None:
1035 account_id = self.__unpack_id(account_id) 996 account_id = self.__unpack_id(account_id)
@@ -1098,13 +1059,13 @@ class Mastodon:
1098 """ 1059 """
1099 id = self.__unpack_id(id) 1060 id = self.__unpack_id(id)
1100 if max_id != None: 1061 if max_id != None:
1101 max_id = self.__unpack_id(max_id) 1062 max_id = self.__unpack_id(max_id, dateconv=True)
1102 1063
1103 if min_id != None: 1064 if min_id != None:
1104 min_id = self.__unpack_id(min_id) 1065 min_id = self.__unpack_id(min_id, dateconv=True)
1105 1066
1106 if since_id != None: 1067 if since_id != None:
1107 since_id = self.__unpack_id(since_id) 1068 since_id = self.__unpack_id(since_id, dateconv=True)
1108 1069
1109 params = self.__generate_params(locals(), ['id']) 1070 params = self.__generate_params(locals(), ['id'])
1110 if pinned == False: 1071 if pinned == False:
@@ -1128,13 +1089,13 @@ class Mastodon:
1128 """ 1089 """
1129 id = self.__unpack_id(id) 1090 id = self.__unpack_id(id)
1130 if max_id != None: 1091 if max_id != None:
1131 max_id = self.__unpack_id(max_id) 1092 max_id = self.__unpack_id(max_id, dateconv=True)
1132 1093
1133 if min_id != None: 1094 if min_id != None:
1134 min_id = self.__unpack_id(min_id) 1095 min_id = self.__unpack_id(min_id, dateconv=True)
1135 1096
1136 if since_id != None: 1097 if since_id != None:
1137 since_id = self.__unpack_id(since_id) 1098 since_id = self.__unpack_id(since_id, dateconv=True)
1138 1099
1139 params = self.__generate_params(locals(), ['id']) 1100 params = self.__generate_params(locals(), ['id'])
1140 url = '/api/v1/accounts/{0}/following'.format(str(id)) 1101 url = '/api/v1/accounts/{0}/following'.format(str(id))
@@ -1149,13 +1110,13 @@ class Mastodon:
1149 """ 1110 """
1150 id = self.__unpack_id(id) 1111 id = self.__unpack_id(id)
1151 if max_id != None: 1112 if max_id != None:
1152 max_id = self.__unpack_id(max_id) 1113 max_id = self.__unpack_id(max_id, dateconv=True)
1153 1114
1154 if min_id != None: 1115 if min_id != None:
1155 min_id = self.__unpack_id(min_id) 1116 min_id = self.__unpack_id(min_id, dateconv=True)
1156 1117
1157 if since_id != None: 1118 if since_id != None:
1158 since_id = self.__unpack_id(since_id) 1119 since_id = self.__unpack_id(since_id, dateconv=True)
1159 1120
1160 params = self.__generate_params(locals(), ['id']) 1121 params = self.__generate_params(locals(), ['id'])
1161 url = '/api/v1/accounts/{0}/followers'.format(str(id)) 1122 url = '/api/v1/accounts/{0}/followers'.format(str(id))
@@ -1460,13 +1421,13 @@ class Mastodon:
1460 id = self.__unpack_id(id) 1421 id = self.__unpack_id(id)
1461 1422
1462 if max_id != None: 1423 if max_id != None:
1463 max_id = self.__unpack_id(max_id) 1424 max_id = self.__unpack_id(max_id, dateconv=True)
1464 1425
1465 if min_id != None: 1426 if min_id != None:
1466 min_id = self.__unpack_id(min_id) 1427 min_id = self.__unpack_id(min_id, dateconv=True)
1467 1428
1468 if since_id != None: 1429 if since_id != None:
1469 since_id = self.__unpack_id(since_id) 1430 since_id = self.__unpack_id(since_id, dateconv=True)
1470 1431
1471 params = self.__generate_params(locals(), ['id']) 1432 params = self.__generate_params(locals(), ['id'])
1472 return self.__api_request('GET', '/api/v1/lists/{0}/accounts'.format(id)) 1433 return self.__api_request('GET', '/api/v1/lists/{0}/accounts'.format(id))
@@ -1482,13 +1443,13 @@ class Mastodon:
1482 Returns a list of `user dicts`_. 1443 Returns a list of `user dicts`_.
1483 """ 1444 """
1484 if max_id != None: 1445 if max_id != None:
1485 max_id = self.__unpack_id(max_id) 1446 max_id = self.__unpack_id(max_id, dateconv=True)
1486 1447
1487 if min_id != None: 1448 if min_id != None:
1488 min_id = self.__unpack_id(min_id) 1449 min_id = self.__unpack_id(min_id, dateconv=True)
1489 1450
1490 if since_id != None: 1451 if since_id != None:
1491 since_id = self.__unpack_id(since_id) 1452 since_id = self.__unpack_id(since_id, dateconv=True)
1492 1453
1493 params = self.__generate_params(locals()) 1454 params = self.__generate_params(locals())
1494 return self.__api_request('GET', '/api/v1/mutes', params) 1455 return self.__api_request('GET', '/api/v1/mutes', params)
@@ -1501,13 +1462,13 @@ class Mastodon:
1501 Returns a list of `user dicts`_. 1462 Returns a list of `user dicts`_.
1502 """ 1463 """
1503 if max_id != None: 1464 if max_id != None:
1504 max_id = self.__unpack_id(max_id) 1465 max_id = self.__unpack_id(max_id, dateconv=True)
1505 1466
1506 if min_id != None: 1467 if min_id != None:
1507 min_id = self.__unpack_id(min_id) 1468 min_id = self.__unpack_id(min_id, dateconv=True)
1508 1469
1509 if since_id != None: 1470 if since_id != None:
1510 since_id = self.__unpack_id(since_id) 1471 since_id = self.__unpack_id(since_id, dateconv=True)
1511 1472
1512 params = self.__generate_params(locals()) 1473 params = self.__generate_params(locals())
1513 return self.__api_request('GET', '/api/v1/blocks', params) 1474 return self.__api_request('GET', '/api/v1/blocks', params)
@@ -1538,13 +1499,13 @@ class Mastodon:
1538 Returns a list of `toot dicts`_. 1499 Returns a list of `toot dicts`_.
1539 """ 1500 """
1540 if max_id != None: 1501 if max_id != None:
1541 max_id = self.__unpack_id(max_id) 1502 max_id = self.__unpack_id(max_id, dateconv=True)
1542 1503
1543 if min_id != None: 1504 if min_id != None:
1544 min_id = self.__unpack_id(min_id) 1505 min_id = self.__unpack_id(min_id, dateconv=True)
1545 1506
1546 if since_id != None: 1507 if since_id != None:
1547 since_id = self.__unpack_id(since_id) 1508 since_id = self.__unpack_id(since_id, dateconv=True)
1548 1509
1549 params = self.__generate_params(locals()) 1510 params = self.__generate_params(locals())
1550 return self.__api_request('GET', '/api/v1/favourites', params) 1511 return self.__api_request('GET', '/api/v1/favourites', params)
@@ -1560,13 +1521,13 @@ class Mastodon:
1560 Returns a list of `user dicts`_. 1521 Returns a list of `user dicts`_.
1561 """ 1522 """
1562 if max_id != None: 1523 if max_id != None:
1563 max_id = self.__unpack_id(max_id) 1524 max_id = self.__unpack_id(max_id, dateconv=True)
1564 1525
1565 if min_id != None: 1526 if min_id != None:
1566 min_id = self.__unpack_id(min_id) 1527 min_id = self.__unpack_id(min_id, dateconv=True)
1567 1528
1568 if since_id != None: 1529 if since_id != None:
1569 since_id = self.__unpack_id(since_id) 1530 since_id = self.__unpack_id(since_id, dateconv=True)
1570 1531
1571 params = self.__generate_params(locals()) 1532 params = self.__generate_params(locals())
1572 return self.__api_request('GET', '/api/v1/follow_requests', params) 1533 return self.__api_request('GET', '/api/v1/follow_requests', params)
@@ -1582,13 +1543,13 @@ class Mastodon:
1582 Returns a list of blocked domain URLs (as strings, without protocol specifier). 1543 Returns a list of blocked domain URLs (as strings, without protocol specifier).
1583 """ 1544 """
1584 if max_id != None: 1545 if max_id != None:
1585 max_id = self.__unpack_id(max_id) 1546 max_id = self.__unpack_id(max_id, dateconv=True)
1586 1547
1587 if min_id != None: 1548 if min_id != None:
1588 min_id = self.__unpack_id(min_id) 1549 min_id = self.__unpack_id(min_id, dateconv=True)
1589 1550
1590 if since_id != None: 1551 if since_id != None:
1591 since_id = self.__unpack_id(since_id) 1552 since_id = self.__unpack_id(since_id, dateconv=True)
1592 1553
1593 params = self.__generate_params(locals()) 1554 params = self.__generate_params(locals())
1594 return self.__api_request('GET', '/api/v1/domain_blocks', params) 1555 return self.__api_request('GET', '/api/v1/domain_blocks', params)
@@ -1692,13 +1653,13 @@ class Mastodon:
1692 Returns a list of `toot dicts`_. 1653 Returns a list of `toot dicts`_.
1693 """ 1654 """
1694 if max_id != None: 1655 if max_id != None:
1695 max_id = self.__unpack_id(max_id) 1656 max_id = self.__unpack_id(max_id, dateconv=True)
1696 1657
1697 if min_id != None: 1658 if min_id != None:
1698 min_id = self.__unpack_id(min_id) 1659 min_id = self.__unpack_id(min_id, dateconv=True)
1699 1660
1700 if since_id != None: 1661 if since_id != None:
1701 since_id = self.__unpack_id(since_id) 1662 since_id = self.__unpack_id(since_id, dateconv=True)
1702 1663
1703 params = self.__generate_params(locals()) 1664 params = self.__generate_params(locals())
1704 return self.__api_request('GET', '/api/v1/bookmarks', params) 1665 return self.__api_request('GET', '/api/v1/bookmarks', params)
@@ -2824,13 +2785,13 @@ class Mastodon:
2824 Returns a list of `admin account dicts`_. 2785 Returns a list of `admin account dicts`_.
2825 """ 2786 """
2826 if max_id != None: 2787 if max_id != None:
2827 max_id = self.__unpack_id(max_id) 2788 max_id = self.__unpack_id(max_id, dateconv=True)
2828 2789
2829 if min_id != None: 2790 if min_id != None:
2830 min_id = self.__unpack_id(min_id) 2791 min_id = self.__unpack_id(min_id, dateconv=True)
2831 2792
2832 if since_id != None: 2793 if since_id != None:
2833 since_id = self.__unpack_id(since_id) 2794 since_id = self.__unpack_id(since_id, dateconv=True)
2834 2795
2835 params = self.__generate_params(locals(), ['remote', 'status', 'staff_only']) 2796 params = self.__generate_params(locals(), ['remote', 'status', 'staff_only'])
2836 2797
@@ -2955,13 +2916,13 @@ class Mastodon:
2955 Returns a list of `report dicts`_. 2916 Returns a list of `report dicts`_.
2956 """ 2917 """
2957 if max_id != None: 2918 if max_id != None:
2958 max_id = self.__unpack_id(max_id) 2919 max_id = self.__unpack_id(max_id, dateconv=True)
2959 2920
2960 if min_id != None: 2921 if min_id != None:
2961 min_id = self.__unpack_id(min_id) 2922 min_id = self.__unpack_id(min_id, dateconv=True)
2962 2923
2963 if since_id != None: 2924 if since_id != None:
2964 since_id = self.__unpack_id(since_id) 2925 since_id = self.__unpack_id(since_id, dateconv=True)
2965 2926
2966 if not account_id is None: 2927 if not account_id is None:
2967 account_id = self.__unpack_id(account_id) 2928 account_id = self.__unpack_id(account_id)
@@ -3027,7 +2988,7 @@ class Mastodon:
3027 2988
3028 ### 2989 ###
3029 # Push subscription crypto utilities 2990 # Push subscription crypto utilities
3030 ### 2991 ###
3031 def push_subscription_generate_keys(self): 2992 def push_subscription_generate_keys(self):
3032 """ 2993 """
3033 Generates a private key, public key and shared secret for use in webpush subscriptions. 2994 Generates a private key, public key and shared secret for use in webpush subscriptions.
@@ -3062,6 +3023,7 @@ class Mastodon:
3062 3023
3063 return priv_dict, pub_dict 3024 return priv_dict, pub_dict
3064 3025
3026 @api_version("2.4.0", "2.4.0", __DICT_VERSION_PUSH_NOTIF)
3065 def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header): 3027 def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header):
3066 """ 3028 """
3067 Decrypts `data` received in a webpush request. Requires the private key dict 3029 Decrypts `data` received in a webpush request. Requires the private key dict
@@ -3810,7 +3772,7 @@ class Mastodon:
3810 3772
3811 return params 3773 return params
3812 3774
3813 def __unpack_id(self, id): 3775 def __unpack_id(self, id, dateconv=False):
3814 """ 3776 """
3815 Internal object-to-id converter 3777 Internal object-to-id converter
3816 3778
@@ -3819,9 +3781,10 @@ class Mastodon:
3819 the id straight. 3781 the id straight.
3820 """ 3782 """
3821 if isinstance(id, dict) and "id" in id: 3783 if isinstance(id, dict) and "id" in id:
3822 return id["id"] 3784 id = id["id"]
3823 else: 3785 if dateconv and isinstance(id, datetime):
3824 return id 3786 id = (int(id) << 16) * 1000
3787 return id
3825 3788
3826 def __decode_webpush_b64(self, data): 3789 def __decode_webpush_b64(self, data):
3827 """ 3790 """
Powered by cgit v1.2.3 (git 2.41.0)