fix bluesky sync

This commit is contained in:
Your Name 2024-11-20 21:46:36 -05:00 committed by Henri Dickson
parent 86a11984d7
commit 563fd4a02f
2 changed files with 17 additions and 4 deletions

View file

@ -153,7 +153,11 @@ class BlueskyAccount(SocialAccount):
def refresh(self, save=True, did_check=True): def refresh(self, save=True, did_check=True):
if did_check: if did_check:
self.check_alive(save=save) 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: if not profile:
logger.warning("Bluesky: client not logged in.") # this should not happen logger.warning("Bluesky: client not logged in.") # this should not happen
return False return False

View file

@ -22,7 +22,7 @@ class Command(BaseCommand):
parser.add_argument( parser.add_argument(
"--integrity", "--integrity",
action="store_true", 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): def handle(self, *args, **options):
@ -33,9 +33,18 @@ class Command(BaseCommand):
def integrity(self): def integrity(self):
count = 0 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 not Preference.objects.filter(user=user).first():
if self.fix: if self.fix:
Preference.objects.create(user=user) Preference.objects.create(user=user)
count += 1 count += 1
print(f"{count} missed preferences") print(f"{count} issues")