Skip to content

Commit

Permalink
Replace follows() with a backwards compat implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
halcy authored and halcy committed Apr 23, 2023
1 parent 77c005c commit b934962
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/06_accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Reading
.. automethod:: Mastodon.endorsements

.. automethod:: Mastodon.account_statuses
.. automethod:: Mastodon.account_following
.. automethod:: Mastodon.account_familiar_followers

.. automethod:: Mastodon.account_lists
Expand Down Expand Up @@ -53,6 +52,7 @@ manage that data - most importantly, follow and unfollow users.
Reading
~~~~~~~
.. automethod:: Mastodon.account_followers
.. automethod:: Mastodon.account_following
.. automethod:: Mastodon.account_relationships
.. automethod:: Mastodon.follows

Expand Down
13 changes: 9 additions & 4 deletions mastodon/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .versions import _DICT_VERSION_ACCOUNT, _DICT_VERSION_STATUS, _DICT_VERSION_RELATIONSHIP, _DICT_VERSION_LIST, _DICT_VERSION_FAMILIAR_FOLLOWERS, _DICT_VERSION_HASHTAG
from .defaults import _DEFAULT_SCOPES, _SCOPE_SETS
from .errors import MastodonIllegalArgumentError, MastodonAPIError
from .errors import MastodonIllegalArgumentError, MastodonAPIError, MastodonNotFoundError
from .utility import api_version

from .internals import Mastodon as Internals
Expand Down Expand Up @@ -321,12 +321,17 @@ def account_follow(self, id, reblogs=True, notify=False):
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
def follows(self, uri):
"""
Follow a remote user by uri (username@domain).
Follow a remote user with username given in username@domain form.
Returns a :ref:`account dict <account dict>`.
Deprecated - avoid using this. Currently uses a backwards compat implementation that may or may not work properly.
"""
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/follows', params)
try:
acct = self.account_search(uri)[0]
except:
raise MastodonNotFoundError("User not found")
return self.account_follow(acct)

@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
def account_unfollow(self, id):
Expand Down

0 comments on commit b934962

Please sign in to comment.