From 2cf02cfb78a7903c6cb73251f8154d4499be7377 Mon Sep 17 00:00:00 2001 From: koalasat Date: Sun, 13 Jul 2025 12:30:28 +0200 Subject: [PATCH] Avoid unnecesary DB queries --- robosats/middleware.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/robosats/middleware.py b/robosats/middleware.py index ddc3aa97..12739db5 100644 --- a/robosats/middleware.py +++ b/robosats/middleware.py @@ -95,9 +95,11 @@ class RobotTokenSHA256AuthenticationMiddleWare: nostr_pubkey = request.META.get("NOSTR_PUBKEY", "").replace( "Nostr ", "" ) - token.user.robot.nostr_pubkey = nostr_pubkey - token.user.robot.save(update_fields=["nostr_pubkey"]) + if token.user.robot.nostr_pubkey != nostr_pubkey: + token.user.robot.nostr_pubkey = nostr_pubkey + + token.user.robot.save(update_fields=["nostr_pubkey"]) # END deprecate after v0.8.0 except Exception: