diff --git a/.gitignore b/.gitignore index 086f9d04..d1edae82 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ migrations/ # debug log file /log -log \ No newline at end of file +log + +# conf folder for neodb +/neodb diff --git a/boofilsic/settings.py b/boofilsic/settings.py index 92b2650e..28d38aef 100644 --- a/boofilsic/settings.py +++ b/boofilsic/settings.py @@ -219,6 +219,10 @@ MASTODON_ALLOW_ANY_SITE = False # Timeout of requests to Mastodon, in seconds MASTODON_TIMEOUT = 30 +MASTODON_CLIENT_SCOPE = 'read write follow' +#use the following if it's a new site +#MASTODON_CLIENT_SCOPE = 'read:accounts read:follows read:search read:blocks read:mutes write:statuses write:media' + # Tags for toots posted from this site MASTODON_TAGS = '#NiceDB #NiceDB%(category)s #NiceDB%(category)s%(type)s' diff --git a/mastodon/api.py b/mastodon/api.py index ab6f5aff..b5dea567 100644 --- a/mastodon/api.py +++ b/mastodon/api.py @@ -96,7 +96,7 @@ def create_app(domain_name): payload = { 'client_name': settings.CLIENT_NAME, - 'scopes': 'read write follow', + 'scopes': settings.MASTODON_CLIENT_SCOPE, 'redirect_uris': settings.REDIRECT_URIS, 'website': settings.APP_WEBSITE } diff --git a/sync/jobs.py b/sync/jobs.py index 519b8618..e6617773 100644 --- a/sync/jobs.py +++ b/sync/jobs.py @@ -233,6 +233,7 @@ class DoufenParser: return self.items except Exception as e: + print('ERROR ' + self.__file_path) logger.error(e) raise e diff --git a/users/templates/users/login.html b/users/templates/users/login.html index 5544066c..3d286307 100644 --- a/users/templates/users/login.html +++ b/users/templates/users/login.html @@ -68,15 +68,9 @@ let domain = selected.val(); Cookies.set('mastodon_domain', domain); - {% if debug %} location.href = "https://" + domain + "/oauth/authorize?client_id=" + client_id + - "&scope=read+write&redirect_uri=http://{{ request.get_host }}{% url 'users:OAuth2_login' %}" + + "&scope={{ scope }}&redirect_uri={{ request.scheme }}://{{ request.get_host }}{% url 'users:OAuth2_login' %}" + "&response_type=code"; - {% else %} - location.href = "https://" + domain + "/oauth/authorize?client_id=" + client_id + - "&scope=read+write&redirect_uri=https://{{ request.get_host }}{% url 'users:OAuth2_login' %}" + - "&response_type=code"; - {% endif %} }); {% endif %} diff --git a/users/views.py b/users/views.py index d11903e8..4768a240 100644 --- a/users/views.py +++ b/users/views.py @@ -26,6 +26,7 @@ from music.forms import MusicMarkStatusTranslator from games.forms import GameMarkStatusTranslator from mastodon.models import MastodonApplication from django.conf import settings +from urllib.parse import quote # Views ######################################## @@ -88,6 +89,7 @@ def login(request): 'users/login.html', { 'sites': sites, + 'scope': quote(settings.MASTODON_CLIENT_SCOPE), 'selected_site': selected_site, 'allow_any_site': settings.MASTODON_ALLOW_ANY_SITE, } @@ -122,7 +124,7 @@ def connect(request): } ) else: - login_url = "https://" + domain + "/oauth/authorize?client_id=" + app.client_id + "&scope=read+write&redirect_uri=" + request.scheme + "://" + request.get_host() + reverse('users:OAuth2_login') + "&response_type=code" + login_url = "https://" + domain + "/oauth/authorize?client_id=" + app.client_id + "&scope=" + quote(settings.MASTODON_CLIENT_SCOPE) + "&redirect_uri=" + request.scheme + "://" + request.get_host() + reverse('users:OAuth2_login') + "&response_type=code" resp = redirect(login_url) resp.set_cookie("mastodon_domain", domain) return resp