Skip to content

Commit 70cd280

Browse files
author
KoalaSat
authored
Merge pull request #2078 from RoboSats/keep-nostr-updated
Avoid unnecesary DB queries
2 parents 0a50432 + 2cf02cf commit 70cd280

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

robosats/middleware.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ def __call__(self, request):
9595
nostr_pubkey = request.META.get("NOSTR_PUBKEY", "").replace(
9696
"Nostr ", ""
9797
)
98-
token.user.robot.nostr_pubkey = nostr_pubkey
9998

100-
token.user.robot.save(update_fields=["nostr_pubkey"])
99+
if token.user.robot.nostr_pubkey != nostr_pubkey:
100+
token.user.robot.nostr_pubkey = nostr_pubkey
101+
102+
token.user.robot.save(update_fields=["nostr_pubkey"])
101103
# END deprecate after v0.8.0
102104

103105
except Exception:

0 commit comments

Comments
 (0)