Skip to content

Commit

Permalink
fix bluesky sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and alphatownsman committed Nov 22, 2024
1 parent 86a1198 commit 563fd4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion mastodon/models/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions users/management/commands/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")

0 comments on commit 563fd4a

Please sign in to comment.