Ryan Lane has submitted this change and it was merged.
Change subject: Compatability with the latest Echo extension version
......................................................................
Compatability with the latest Echo extension version
Change-Id: I78495171b36fbae1e0a1508a44ecfdfc0bc525e2
---
M OpenStackManager.i18n.php
M OpenStackManager.php
M maintenance/onInstanceActionCompletion.php
3 files changed, 43 insertions(+), 25 deletions(-)
Approvals:
Ryan Lane: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/OpenStackManager.i18n.php b/OpenStackManager.i18n.php
index c304c9e..1339266 100644
--- a/OpenStackManager.i18n.php
+++ b/OpenStackManager.i18n.php
@@ -421,9 +421,9 @@
'notification-osm-instance-deleted' => '$1 deleted instance \'$3\' in
project [[$2]]',
'notification-osm-instance-build-completed' => '$1 built instance
\'$3\' in project [[$2]]',
'notification-osm-instance-reboot-completed' => '$1 rebooted instance
\'$3\' in project [[$2]]',
- 'echo-pref-email-osm-instance-deleted' => 'Deletes an instance from a
project I\'m a admin on.',
- 'echo-pref-email-osm-instance-build-completed' => 'Builds an instance
on a project I\'m a admin on.',
- 'echo-pref-email-osm-instance-reboot-completed' => 'Reboots an
instance.',
+ 'echo-pref-subscription-osm-instance-deleted' => 'Deletes an instance
from a project I\'m an admin on.',
+ 'echo-pref-subscription-osm-instance-build-completed' => 'Builds an
instance on a project I\'m an admin on.',
+ 'echo-pref-subscription-osm-instance-reboot-completed' => 'Reboots an
instance.',
'prefs-openstack' => 'OpenStack',
'prefs-openstack-keys' => 'Key list',
diff --git a/OpenStackManager.php b/OpenStackManager.php
index 5162176..528ba46 100644
--- a/OpenStackManager.php
+++ b/OpenStackManager.php
@@ -241,33 +241,46 @@
return true;
}
-$wgEchoNotificationFormatters['osm-instance-build-completed'] = array(
- 'class' => 'OpenStackManagerNotificationFormatter',
+$wgEchoNotifications['osm-instance-build-completed'] = array(
+ 'formatter-class' => 'OpenStackManagerNotificationFormatter',
+ 'category' => 'osm-instance-build-completed',
'title-message' => 'notification-osm-instance-build-completed',
'title-params' => array( 'agent', 'title', 'instance' ),
'icon' => 'placeholder',
'payload' => array( 'summary' )
);
+$wgEchoNotificationCategories['osm-instance-build-completed'] = array(
+ 'priority' => 10
+);
+$wgDefaultUserOptions["echo-subscriptions-web-osm-instance-build-completed"] =
true;
+$wgDefaultUserOptions["echo-subscriptions-email-osm-instance-build-completed"]
= true;
-$wgEchoNotificationFormatters['osm-instance-reboot-completed'] = array(
- 'class' => 'OpenStackManagerNotificationFormatter',
+$wgEchoNotifications['osm-instance-reboot-completed'] = array(
+ 'formatter-class' => 'OpenStackManagerNotificationFormatter',
+ 'category' => 'osm-instance-reboot-completed',
'title-message' => 'notification-osm-instance-reboot-completed',
'title-params' => array( 'agent', 'title', 'instance' ),
'icon' => 'placeholder',
'payload' => array( 'summary' )
);
+$wgEchoNotificationCategories['osm-instance-reboot-completed'] = array(
+ 'priority' => 10
+);
+$wgDefaultUserOptions["echo-subscriptions-web-osm-instance-reboot-completed"]
= true;
-$wgEchoNotificationFormatters['osm-instance-deleted'] = array(
- 'class' => 'OpenStackManagerNotificationFormatter',
+$wgEchoNotifications['osm-instance-deleted'] = array(
+ 'formatter-class' => 'OpenStackManagerNotificationFormatter',
+ 'category' => 'osm-instance-deleted',
'title-message' => 'notification-osm-instance-deleted',
'title-params' => array( 'agent', 'title', 'instance' ),
'icon' => 'trash',
'payload' => array( 'summary' )
);
-
-$wgEchoEnabledEvents[] = 'osm-instance-build-completed';
-$wgEchoEnabledEvents[] = 'osm-instance-reboot-completed';
-$wgEchoEnabledEvents[] = 'osm-instance-deleted';
+$wgEchoNotificationCategories['osm-instance-deleted'] = array(
+ 'priority' => 10
+);
+$wgDefaultUserOptions["echo-subscriptions-web-osm-instance-deleted"] = true;
+$wgDefaultUserOptions["echo-subscriptions-email-osm-instance-deleted"] = true;
/**
* @param $updater DatabaseUpdater
diff --git a/maintenance/onInstanceActionCompletion.php
b/maintenance/onInstanceActionCompletion.php
index 2a73523..1027c13 100644
--- a/maintenance/onInstanceActionCompletion.php
+++ b/maintenance/onInstanceActionCompletion.php
@@ -78,7 +78,7 @@
$this->error( "Lookup of temporary event info
failed.\n", true );
}
- EchoEvent::create( array(
+ $successful = EchoEvent::create( array(
'type' => 'osm-instance-' . $this->getOption( 'action'
) . '-completed',
'title' => Title::newFromText( $result->event_project,
NS_NOVA_RESOURCE ),
'agent' => User::newFromId( $result->event_actor_id ),
@@ -89,17 +89,22 @@
)
) );
- $dbw->delete(
- 'openstack_notification_event',
- array(
- 'event_action' => $this->getOption( 'action' ),
- 'event_instance_host' => $this->getOption(
'instance' ),
- 'event_instance_name' =>
$result->event_instance_name,
- 'event_project' => $result->event_project,
- 'event_actor_id' => $result->event_actor_id
- ),
- __METHOD__
- );
+ if ( $successful ) {
+ $dbw->delete(
+ 'openstack_notification_event',
+ array(
+ 'event_action' => $this->getOption(
'action' ),
+ 'event_instance_host' =>
$this->getOption( 'instance' ),
+ 'event_instance_name' =>
$result->event_instance_name,
+ 'event_project' =>
$result->event_project,
+ 'event_actor_id' =>
$result->event_actor_id
+ ),
+ __METHOD__
+ );
+ $this->output( "Event created successfully.\n" );
+ } else {
+ $this->error( "Something went wrong creating the echo
notification.\n", true );
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/58226
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I78495171b36fbae1e0a1508a44ecfdfc0bc525e2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Ryan Lane <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits