diff --git a/.coverage b/.coverage index 3a8c3ed..463cb35 100644 Binary files a/.coverage and b/.coverage differ diff --git a/src/mastodon/statuses.py b/src/mastodon/statuses.py index 2450c64..8040cf8 100644 --- a/src/mastodon/statuses.py +++ b/src/mastodon/statuses.py @@ -19,6 +19,19 @@ class Statuses(): else: raise RuntimeError("Server returned {} {}".format(response.status_code, response.content)) + def unfavourite(self, status_id): + server = self.config.get_value("server") + url = f"https://{server}/api/v1/statuses/{status_id}/unfavourite" + + response = requests.post(url, headers=self.auth.get_auth_headers()) + + logger.trace("JSON: {}".format(str(response.content))) + if response.status_code == 200: + return response.json() + else: + raise RuntimeError("Server returned {} {}".format(response.status_code, response.content)) + + def reblog(self, status_id): server = self.config.get_value("server") url = f"https://{server}/api/v1/statuses/{status_id}/reblog" @@ -30,3 +43,15 @@ class Statuses(): return response.json() else: raise RuntimeError("Server returned {} {}".format(response.status_code, response.content)) + + def unreblog(self, status_id): + server = self.config.get_value("server") + url = f"https://{server}/api/v1/statuses/{status_id}/unreblog" + + response = requests.post(url, headers=self.auth.get_auth_headers()) + + logger.trace("JSON: {}".format(str(response.content))) + if response.status_code == 200: + return response.json() + else: + raise RuntimeError("Server returned {} {}".format(response.status_code, response.content)) diff --git a/tests/resources/unfavourite_response.json b/tests/resources/unfavourite_response.json new file mode 100644 index 0000000..e93e0d0 --- /dev/null +++ b/tests/resources/unfavourite_response.json @@ -0,0 +1,142 @@ +{ + "id": "103270115826048975", + "created_at": "2019-12-08T03:48:33.901Z", + "in_reply_to_id": null, + "in_reply_to_account_id": null, + "sensitive": false, + "spoiler_text": "", + "visibility": "public", + "language": "en", + "uri": "https://mastodon.social/users/Gargron/statuses/103270115826048975", + "url": "https://mastodon.social/@Gargron/103270115826048975", + "replies_count": 5, + "reblogs_count": 6, + "favourites_count": 11, + "favourited": false, + "reblogged": false, + "muted": false, + "bookmarked": false, + "content": "
"I lost my inheritance with one wrong digit on my sort code"
https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code",
+ "reblog": null,
+ "application": {
+ "name": "Web",
+ "website": null
+ },
+ "account": {
+ "id": "1",
+ "username": "Gargron",
+ "acct": "Gargron",
+ "display_name": "Eugen",
+ "locked": false,
+ "bot": false,
+ "discoverable": true,
+ "group": false,
+ "created_at": "2016-03-16T14:34:26.392Z",
+ "note": " Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.
https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code",
+ "reblog": null,
+ "application": {
+ "name": "Web",
+ "website": null
+ },
+ "account": {
+ "id": "1",
+ "username": "Gargron",
+ "acct": "Gargron",
+ "display_name": "Eugen",
+ "locked": false,
+ "bot": false,
+ "discoverable": true,
+ "group": false,
+ "created_at": "2016-03-16T14:34:26.392Z",
+ "note": " Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.