diff --git a/files/classes/user.py b/files/classes/user.py index d0589f88c..b263c52b1 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -490,6 +490,7 @@ class User(Base): def referral_count(self): return len(self.referrals) + @lazy def has_blocked(self, target): return db.query(UserBlock).filter_by(user_id=self.id, target_id=target.id).one_or_none() diff --git a/files/helpers/lazy.py b/files/helpers/lazy.py index 682d3258a..eed02733e 100644 --- a/files/helpers/lazy.py +++ b/files/helpers/lazy.py @@ -1,3 +1,5 @@ +from flask import g + def lazy(f): ''' Prevents certain properties from having to be recomputed each time they are referenced @@ -6,7 +8,7 @@ def lazy(f): o = args[0] if "_lazy" not in o.__dict__: o.__dict__["_lazy"] = {} - name = f.__name__ + str(args) + str(kwargs), + name = f.__name__ + str(args) + str(kwargs) + g.nonce, if name not in o.__dict__["_lazy"]: o.__dict__["_lazy"][name] = f(*args, **kwargs) return o.__dict__["_lazy"][name]