From e1f410151eec0f31996172c068a909c879bc698d Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Thu, 4 Jan 2024 17:07:02 +1300 Subject: [PATCH] oops --- app/activitypub/routes.py | 6 +++--- app/auth/routes.py | 2 +- app/community/routes.py | 2 +- app/utils.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index b36e68fe..ca5e9573 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -529,7 +529,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): member = CommunityMember(user_id=user.id, community_id=community.id) db.session.add(member) db.session.commit() - cache.delete_memoized('community_membership', user, community) + cache.delete_memoized(community_membership, user, community) # send accept message to acknowledge the follow accept = { "@context": default_context(), @@ -568,7 +568,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): community.subscriptions_count += 1 db.session.commit() activity_log.result = 'success' - cache.delete_memoized('community_membership', user, community) + cache.delete_memoized(community_membership, user, community) elif request_json['type'] == 'Undo': if request_json['object']['type'] == 'Follow': # Unsubscribe from a community @@ -586,7 +586,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): if join_request: db.session.delete(join_request) db.session.commit() - cache.delete_memoized('community_membership', user, community) + cache.delete_memoized(community_membership, user, community) activity_log.result = 'success' elif request_json['object']['type'] == 'Like': # Undoing an upvote or downvote activity_log.activity_type = request_json['object']['type'] diff --git a/app/auth/routes.py b/app/auth/routes.py index ac31059a..9d49573d 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -50,7 +50,7 @@ def login(): new_ip_ban = IpBan(ip_address=ip_address(), notes=user.user_name + ' used new IP address') db.session.add(new_ip_ban) db.session.commit() - cache.delete_memoized('banned_ip_addresses') + cache.delete_memoized(banned_ip_addresses) # Set a cookie so we have another way to track banned people response.set_cookie('sesion', '17489047567495', expires=datetime(year=2099, month=12, day=30)) diff --git a/app/community/routes.py b/app/community/routes.py index 704e1e32..c4535e96 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -285,7 +285,7 @@ def unsubscribe(actor): db.session.commit() flash('You are unsubscribed from ' + community.title) - cache.delete_memoized('community_membership', current_user, community) + cache.delete_memoized(community_membership, current_user, community) else: # todo: community deletion diff --git a/app/utils.py b/app/utils.py index 97976e54..d3ea2eb7 100644 --- a/app/utils.py +++ b/app/utils.py @@ -257,7 +257,7 @@ def user_access(permission: str, user_id: int) -> bool: return has_access is not None -@cache.memoize(timeout=86400) +@cache.memoize(timeout=10) def community_membership(user: User, community: Community) -> int: # @cache.memoize works with User.subscribed but cache.delete_memoized does not, making it bad to use on class methods. # however cache.memoize and cache.delete_memoized works fine with normal functions