do not show user profile if deactivated
This commit is contained in:
parent
2059f45c22
commit
6e48bb90ea
3 changed files with 15 additions and 1 deletions
|
@ -516,6 +516,9 @@ CORS_ALLOW_METHODS = (
|
|||
"POST",
|
||||
# "PUT",
|
||||
)
|
||||
|
||||
DEACTIVATE_AFTER_UNREACHABLE_DAYS = 120
|
||||
|
||||
DEFAULT_RELAY_SERVER = "https://relay.neodb.net/actor"
|
||||
|
||||
SENTRY_DSN = env("NEODB_SENTRY_DSN")
|
||||
|
|
|
@ -37,6 +37,9 @@ def target_identity_required(func):
|
|||
target = APIdentity.get_by_handler(user_name)
|
||||
except APIdentity.DoesNotExist:
|
||||
return render_user_not_found(request)
|
||||
target_user = target.user
|
||||
if target_user and not target_user.is_active:
|
||||
return render_user_not_found(request)
|
||||
if not target.is_visible_to_user(request.user):
|
||||
return render_user_blocked(request)
|
||||
request.target_identity = target
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import hashlib
|
||||
import re
|
||||
from datetime import timedelta
|
||||
from functools import cached_property
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
|
||||
|
@ -275,7 +276,14 @@ class User(AbstractUser):
|
|||
self.mastodon_last_refresh = timezone.now()
|
||||
if not webfinger(self.mastodon_site, self.mastodon_username):
|
||||
logger.error(f"Unable to fetch web finger for {self}")
|
||||
self.save(update_fields=["mastodon_last_refresh"])
|
||||
if (
|
||||
timezone.now() - self.mastodon_last_reachable
|
||||
> timedelta(days=settings.DEACTIVATE_AFTER_UNREACHABLE_DAYS)
|
||||
and not self.email
|
||||
):
|
||||
logger.warning(f"Deactivate {self} bc unable to reach for too long")
|
||||
self.is_active = False
|
||||
self.save(update_fields=["mastodon_last_refresh", "is_active"])
|
||||
return False
|
||||
self.mastodon_last_reachable = timezone.now()
|
||||
code, mastodon_account = verify_account(self.mastodon_site, self.mastodon_token)
|
||||
|
|
Loading…
Add table
Reference in a new issue