This commit is contained in:
rimu 2024-01-04 17:07:02 +13:00
parent 82422c06c6
commit e1f410151e
4 changed files with 6 additions and 6 deletions

View file

@ -529,7 +529,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address):
member = CommunityMember(user_id=user.id, community_id=community.id) member = CommunityMember(user_id=user.id, community_id=community.id)
db.session.add(member) db.session.add(member)
db.session.commit() db.session.commit()
cache.delete_memoized('community_membership', user, community) cache.delete_memoized(community_membership, user, community)
# send accept message to acknowledge the follow # send accept message to acknowledge the follow
accept = { accept = {
"@context": default_context(), "@context": default_context(),
@ -568,7 +568,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address):
community.subscriptions_count += 1 community.subscriptions_count += 1
db.session.commit() db.session.commit()
activity_log.result = 'success' activity_log.result = 'success'
cache.delete_memoized('community_membership', user, community) cache.delete_memoized(community_membership, user, community)
elif request_json['type'] == 'Undo': elif request_json['type'] == 'Undo':
if request_json['object']['type'] == 'Follow': # Unsubscribe from a community 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: if join_request:
db.session.delete(join_request) db.session.delete(join_request)
db.session.commit() db.session.commit()
cache.delete_memoized('community_membership', user, community) cache.delete_memoized(community_membership, user, community)
activity_log.result = 'success' activity_log.result = 'success'
elif request_json['object']['type'] == 'Like': # Undoing an upvote or downvote elif request_json['object']['type'] == 'Like': # Undoing an upvote or downvote
activity_log.activity_type = request_json['object']['type'] activity_log.activity_type = request_json['object']['type']

View file

@ -50,7 +50,7 @@ def login():
new_ip_ban = IpBan(ip_address=ip_address(), notes=user.user_name + ' used new IP address') new_ip_ban = IpBan(ip_address=ip_address(), notes=user.user_name + ' used new IP address')
db.session.add(new_ip_ban) db.session.add(new_ip_ban)
db.session.commit() 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 # 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)) response.set_cookie('sesion', '17489047567495', expires=datetime(year=2099, month=12, day=30))

View file

@ -285,7 +285,7 @@ def unsubscribe(actor):
db.session.commit() db.session.commit()
flash('You are unsubscribed from ' + community.title) flash('You are unsubscribed from ' + community.title)
cache.delete_memoized('community_membership', current_user, community) cache.delete_memoized(community_membership, current_user, community)
else: else:
# todo: community deletion # todo: community deletion

View file

@ -257,7 +257,7 @@ def user_access(permission: str, user_id: int) -> bool:
return has_access is not None return has_access is not None
@cache.memoize(timeout=86400) @cache.memoize(timeout=10)
def community_membership(user: User, community: Community) -> int: 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. # @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 # however cache.memoize and cache.delete_memoized works fine with normal functions