Replace follows() with a backwards compat implementation

pull/339/head
halcy 2023-04-23 20:28:24 +03:00
rodzic 77c005c899
commit b934962069
2 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

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

Wyświetl plik

@ -4,7 +4,7 @@ import collections
from .versions import _DICT_VERSION_ACCOUNT, _DICT_VERSION_STATUS, _DICT_VERSION_RELATIONSHIP, _DICT_VERSION_LIST, _DICT_VERSION_FAMILIAR_FOLLOWERS, _DICT_VERSION_HASHTAG 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 .defaults import _DEFAULT_SCOPES, _SCOPE_SETS
from .errors import MastodonIllegalArgumentError, MastodonAPIError from .errors import MastodonIllegalArgumentError, MastodonAPIError, MastodonNotFoundError
from .utility import api_version from .utility import api_version
from .internals import Mastodon as Internals from .internals import Mastodon as Internals
@ -321,12 +321,17 @@ class Mastodon(Internals):
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT) @api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
def follows(self, uri): 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>`. 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()) try:
return self.__api_request('POST', '/api/v1/follows', params) 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) @api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
def account_unfollow(self, id): def account_unfollow(self, id):