diff --git a/mastodon/models/bluesky.py b/mastodon/models/bluesky.py index c6cab270..65b95f91 100644 --- a/mastodon/models/bluesky.py +++ b/mastodon/models/bluesky.py @@ -153,7 +153,11 @@ def check_alive(self, save=True): def refresh(self, save=True, did_check=True): if did_check: self.check_alive(save=save) - profile = self._client.me + try: + profile = self._client.me + except Exception: + logger.warning("Bluesky: client error.") + return False if not profile: logger.warning("Bluesky: client not logged in.") # this should not happen return False diff --git a/users/management/commands/user.py b/users/management/commands/user.py index 1287cac8..5c048aa2 100644 --- a/users/management/commands/user.py +++ b/users/management/commands/user.py @@ -22,7 +22,7 @@ def add_arguments(self, parser): parser.add_argument( "--integrity", action="store_true", - help="check and fix integrity for merged and deleted items", + help="check and fix integrity for missing data for user models", ) def handle(self, *args, **options): @@ -33,9 +33,18 @@ def handle(self, *args, **options): def integrity(self): count = 0 - for user in tqdm(User.objects.all()): + for user in tqdm(User.objects.filter(is_active=True)): + i = user.identity.takahe_identity + if i.public_key is None: + count += 1 + if self.fix: + i.generate_keypair() + if i.inbox_uri is None: + count += 1 + if self.fix: + i.ensure_uris() if not Preference.objects.filter(user=user).first(): if self.fix: Preference.objects.create(user=user) count += 1 - print(f"{count} missed preferences") + print(f"{count} issues")