summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Attachment.pm3
-rw-r--r--Bugzilla/Hook.pm24
-rw-r--r--extensions/ZPushNotify/Extension.pm35
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<Bugzilla::Attachment/update>, after changes are made
+to the database, but while still inside a transaction.
+
+Params:
+
+=over
+
+=item C<object>
+
+The attachment object that C<update> was called on.
+
+=item C<old_object>
+
+The attachment object as it was before it was updated.
+
+=item C<changes>
+
+The fields that have been changed, in the same format that
+L<Bugzilla::Attachment/update> 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);
}
}