diff options
-rw-r--r-- | Bugzilla/Bug.pm | 6 | ||||
-rw-r--r-- | Bugzilla/BugUserLastVisit.pm | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 3310afe3d..0c2f659c5 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1122,6 +1122,12 @@ sub update { $self->update_user_last_visit($user, $delta_ts); } + # If a user is no longer involved, remove their last visit entry + my $last_visits = Bugzilla::BugUserLastVisit->match({bug_id => $self->id}); + foreach my $lv (@$last_visits) { + $lv->remove_from_db() unless $lv->user->is_involved_with_bug($self); + } + # Update bug ignore data if user wants to ignore mail for this bug if (exists $self->{'bug_ignored'}) { my $bug_ignored_changed; diff --git a/Bugzilla/BugUserLastVisit.pm b/Bugzilla/BugUserLastVisit.pm index c4acfa56b..6a7b7f3ef 100644 --- a/Bugzilla/BugUserLastVisit.pm +++ b/Bugzilla/BugUserLastVisit.pm @@ -38,6 +38,13 @@ sub bug_id { return $_[0]->{bug_id} } sub user_id { return $_[0]->{user_id} } sub last_visit_ts { return $_[0]->{last_visit_ts} } +sub user { + my $self = shift; + + $self->{user} //= Bugzilla::User->new({id => $self->user_id, cache => 1}); + return $self->{user}; +} + 1; __END__ @@ -80,4 +87,6 @@ listed below. =item C<last_visit_ts> +=item C<user> + =back |