Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/8451 #8460

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/pf/UnifiedApi/Controller/Crud.pm
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,19 @@ sub do_remove {
return ($status, $msg);
}

return $self->dal->remove_by_id($self->build_item_lookup);
$self->pre_remove();
($status, $msg) = $self->dal->remove_by_id($self->build_item_lookup);
if (is_error($status)) {
return ($status, $msg);
}

$self->post_remove();
return ($status, $msg);
}

sub pre_remove { }
sub post_remove { }

sub can_remove {
return (200, '');
}
Expand Down
13 changes: 13 additions & 0 deletions lib/pf/UnifiedApi/Controller/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ use pf::security_event;
use pf::constants;
use pf::person qw(person_security_events person_unassign_nodes person_delete person_modify);
use pf::node;
use pf::lookup::person;
use pf::constants qw($default_pid);
use pf::constants::realm;
use pf::error qw(is_error is_success);
use pf::UnifiedApi::Search::Builder::Users;
use pf::lookup::person qw();

has 'search_builder_class' => 'pf::UnifiedApi::Search::Builder::Users';

Expand Down Expand Up @@ -658,6 +661,16 @@ sub _can_remove {
}
}

sub post_delete {
my ($self) = @_;
my $item = $self->item;
my $source = $item->{source};
for my $ctx ('', @pf::constants::realm::CONTEXTS) {
pf::lookup::person::clear_lookup_person($self->id, $item->{source}, $ctx);
}

}

=head1 AUTHOR

Inverse inc. <[email protected]>
Expand Down
10 changes: 9 additions & 1 deletion lib/pf/lookup/person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use pf::authentication;
use pf::pfqueue::producer::redis;
use pf::CHI;

my $CHI_CACHE = pf::CHI->new( namespace => 'person_lookup' );
our $CHI_CACHE = pf::CHI->new( namespace => 'person_lookup' );

=head2 lookup_person

Expand Down Expand Up @@ -91,6 +91,14 @@ sub async_lookup_person {
$client->submit("general", person_lookup => {pid => $pid, source_id => $source_id, context => $context});
}

sub clear_lookup_person {
my ($pid, $source_id, $context) = @_;
my $logger = get_logger();
my $cache_key = "$source_id.$pid.$context";
$CHI_CACHE->remove($cache_key);
$logger->info("Clear cache for pid $pid with key $cache_key");
}

=head1 AUTHOR

Inverse inc. <[email protected]>
Expand Down
Loading