fix: cache invalidation on new members invite (#4699)

This commit is contained in:
Nikhil 2024-06-05 15:17:43 +05:30 committed by sriram veeraghanta
parent 272428b05e
commit 30fdc1015c
2 changed files with 12 additions and 1 deletions

View File

@ -4,6 +4,7 @@ from plane.db.models import (
WorkspaceMember, WorkspaceMember,
WorkspaceMemberInvite, WorkspaceMemberInvite,
) )
from plane.utils.cache import invalidate_cache_directly
def process_workspace_project_invitations(user): def process_workspace_project_invitations(user):
@ -26,6 +27,16 @@ def process_workspace_project_invitations(user):
ignore_conflicts=True, ignore_conflicts=True,
) )
[
invalidate_cache_directly(
path=f"/api/workspaces/{str(workspace_member_invite.workspace.slug)}/members/",
url_params=False,
user=False,
multiple=True,
)
for workspace_member_invite in workspace_member_invites
]
# Check if user has any project invites # Check if user has any project invites
project_member_invites = ProjectMemberInvite.objects.filter( project_member_invites = ProjectMemberInvite.objects.filter(
email=user.email, accepted=True email=user.email, accepted=True

View File

@ -66,7 +66,7 @@ def invalidate_cache_directly(
custom_path = path if path is not None else request.get_full_path() custom_path = path if path is not None else request.get_full_path()
auth_header = ( auth_header = (
None None
if request.user.is_anonymous if request and request.user.is_anonymous
else str(request.user.id) if user else None else str(request.user.id) if user else None
) )
key = generate_cache_key(custom_path, auth_header) key = generate_cache_key(custom_path, auth_header)