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 --- extensions/ZPushNotify/Extension.pm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'extensions/ZPushNotify') 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