From c2533c1f2e7c5c4376eb0dae17c3380b04067678 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 10 Nov 2014 16:43:03 +0000 Subject: Bug 1067619: Pulse is not notified of changes to attachment flags --- Bugzilla/Attachment.pm | 3 +++ Bugzilla/Hook.pm | 24 ++++++++++++++++++++++++ extensions/ZPushNotify/Extension.pm | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 1302fc716..33a4c55a5 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -922,6 +922,9 @@ sub update { Bugzilla->memcached->clear({ table => 'attachments', id => $self->id }); } + Bugzilla::Hook::process('attachment_end_of_update', + { object => $self, old_object => $old_self, changes => $changes }); + return $changes; } diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index 5e3dca655..fff102232 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -151,6 +151,30 @@ This is a Bugzilla::User object of the user. =back +=head2 attachment_end_of_update + +Called during L, after changes are made +to the database, but while still inside a transaction. + +Params: + +=over + +=item C + +The attachment object that C was called on. + +=item C + +The attachment object as it was before it was updated. + +=item C + +The fields that have been changed, in the same format that +L returns. + +=back + =head2 attachment_process_data This happens at the very beginning process of the attachment creation. diff --git a/extensions/ZPushNotify/Extension.pm b/extensions/ZPushNotify/Extension.pm index 6e8ab4d27..e31380cfe 100644 --- a/extensions/ZPushNotify/Extension.pm +++ b/extensions/ZPushNotify/Extension.pm @@ -31,14 +31,38 @@ sub _notify { # object hooks # -sub object_end_of_update { +sub object_end_of_create { + my ($self, $args) = @_; + my $object = $args->{object}; + return unless Bugzilla->params->{enable_simple_push}; + return unless $object->isa('Bugzilla::Flag'); + _notify($object->bug->id, $object->creation_date); +} + +sub flag_updated { + my ($self, $args) = @_; + my $flag = $args->{flag}; + my $timestamp = $args->{timestamp}; + my $changes = $args->{changes}; + return unless Bugzilla->params->{enable_simple_push}; + return unless scalar(keys %$changes); + _notify($flag->bug->id, $timestamp); +} + +sub flag_deleted { + my ($self, $args) = @_; + my $flag = $args->{flag}; + my $timestamp = $args->{timestamp}; + return unless Bugzilla->params->{enable_simple_push}; + _notify($flag->bug->id, $timestamp); +} + +sub attachment_end_of_update { my ($self, $args) = @_; return unless Bugzilla->params->{enable_simple_push}; return unless scalar keys %{ $args->{changes} }; return unless my $object = $args->{object}; - if ($object->isa('Bugzilla::Attachment')) { - _notify($object->bug->id, $object->bug->delta_ts); - } + _notify($object->bug->id, $object->modification_time); } sub object_before_delete { @@ -46,7 +70,8 @@ sub object_before_delete { return unless Bugzilla->params->{enable_simple_push}; return unless my $object = $args->{object}; if ($object->isa('Bugzilla::Attachment')) { - _notify($object->bug->id, $object->bug->delta_ts); + my $timestamp = Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + _notify($object->bug->id, $timestamp); } } -- cgit v1.2.3-24-g4f1b