Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bluesky sync #776

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")