Commit 48d60755 authored by jaywink's avatar jaywink
Browse files

Avoid unnecessary Profile saves

Avoid unnecessary Profile object saves when finding sender profiles and nothing for the
  remote profile has changed.
parent ad0ad030
......@@ -35,6 +35,9 @@ Fixed
* Fix share retraction towards ActivityPub platforms.
* Avoid unnecessary Profile object saves when finding sender profiles and nothing for the
remote profile has changed.
0.12.1 (2020-12-12)
-------------------
......
......@@ -27,7 +27,7 @@ class ProfileQuerySet(QuerySet):
).filter(**params)
def fed_update_or_create(
self, fid: str, values: Dict[str, Any], extra_lookups: Dict=None
self, fid: str, values: Dict[str, Any], extra_lookups: Dict = None
) -> Tuple['Profile', bool]:
"""
Update or create by federated ID.
......@@ -42,15 +42,20 @@ class ProfileQuerySet(QuerySet):
values.update(extra_lookups)
return self.create(**values), True
else:
changed = False
for key, value in values.items():
if key in ('fid', 'guid', 'handle'):
continue
if getattr(profile, key, None) != value:
changed = True
setattr(profile, key, value)
# Switch profile to ActivityPub if Diaspora and we got an ActivityPub payload,
# indicating this is a multi-protocol remote
if profile.protocol == "diaspora" and profile.fid:
profile.protocol = "activitypub"
profile.save()
changed = True
if changed:
profile.save()
return profile, False
def followers(self, profile):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment