Skip to content

Commit

Permalink
Add account_familiar_followers
Browse files Browse the repository at this point in the history
  • Loading branch information
halcy authored and halcy committed Nov 27, 2022
1 parent ee9a3c9 commit b35e3f3
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version number. Breaking changes will be indicated by a change in the minor

v1.8.0 (in progress)
--------------------
* Overall: Support level is now 3.5.3 (last before 4.0.0)
* BREAKING CHANGE: Switch the base URL to None, throw an error when no base url is passed. Having mastosoc as default was sensible when there were only three mastodon servers. It is not sensible now and trips people up constantly.
* Fixed an issue with the fix for the Pleroma date bug (thanks adbenitez)
* Added trending APIs (`trending_tags`, `trending_statuses`, `trending_links`, `admin_trending_tags`, `admin_trending_statuses`, `admin_trending_links`)
Expand All @@ -14,6 +15,7 @@ v1.8.0 (in progress)
* Added the domain blocking admin API (`admin_domain_blocks`, `admin_domain_block`, `admin_update_domain_block`, `admin_delete_domain_block` - thanks catgoat)
* Added the stats admin APIs (`admin_measures`, `admin_dimensions`, `admin_retention`)
* Added client auth data to access token file.
* Added `account_familiar_followers` API

v1.7.0
------
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Refer to mastodon changelog and API docs for details when implementing, add or m
* [x] Add notifications for posts deleted by moderators <- by email. not actually API relevant.
* [x] Add explore page with trending posts and links
* [x] Add graphs and retention metrics to admin dashboard
* [ ] Add GET /api/v1/accounts/familiar_followers to REST API
* [x] Add GET /api/v1/accounts/familiar_followers to REST API
* [ ] Add POST /api/v1/accounts/:id/remove_from_followers to REST API
* [x] Add category and rule_ids params to POST /api/v1/reports IN REST API
* [x] Add global lang param to REST API
Expand Down
15 changes: 14 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,18 @@ Announcement dicts
} ],
}
Familiar follower dicts
~~~~~~~~~~~~~~~~~~~~~~~
.. _familiar follower dict:
.. code-block:: python
mastodon.account_familiar_followers(1)[0]
# Returns the following dictionary:
{
}
Admin account dicts
~~~~~~~~~~~~~~~~~~~
.. _admin account dict:
Expand Down Expand Up @@ -1087,8 +1099,9 @@ their relationships.
.. automethod:: Mastodon.account_followers
.. automethod:: Mastodon.account_relationships
.. automethod:: Mastodon.account_search
.. automethod:: Mastodon.account_lists
.. automethod:: Mastodon.account_lookup
.. automethod:: Mastodon.account_lists
.. automethod:: Mastodon.account_familiar_followers
Reading data: Featured tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
26 changes: 20 additions & 6 deletions mastodon/Mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,13 @@ def __init__(self, client_id=None, client_secret=None, access_token=None, api_ba
self.api_base_url = try_base_url

# For EVEN newer vesions, we ALSO ALSO store the client id and secret so that you don't need to reauth to revoke
try:
self.client_id = token_file.readline().rstrip()
self.client_secret = token_file.readline().rstrip()
except:
pass

if self.client_id is None:
try:
self.client_id = token_file.readline().rstrip()
self.client_secret = token_file.readline().rstrip()
except:
pass

# Verify we have a base URL, protocolize
if self.api_base_url is None:
raise MastodonIllegalArgumentError("API base URL is required.")
Expand Down Expand Up @@ -1356,6 +1357,19 @@ def account_lookup(self, acct):
"""
return self.__api_request('GET', '/api/v1/accounts/lookup', self.__generate_params(locals()))

@api_version("3.5.0", "3.5.0", __DICT_VERSION_ACCOUNT)
def account_familiar_followers(self, id):
"""
Find followers for the account given by id (can be a list) that also follow the
logged in account.
Returns a list of `familiar follower dicts`_
"""
if not isinstance(id, list):
id = [id]
for i in range(len(id)):
id[i] = self.__unpack_id(id[i])
return self.__api_request('GET', '/api/v1/accounts/familiar_followers', {'id': id}, use_json=True)

###
# Reading data: Featured hashtags
Expand Down

0 comments on commit b35e3f3

Please sign in to comment.