Remove Assignee Changed event from plugin. Assignee is being removed from gerrit. This example will stop working once it is removed. Google-Bug-Id: b/33429040 Release-Notes: skip Change-Id: I4e692e33a178eb9df2b14b1f6d3aa4b3185f6067
diff --git a/src/main/java/com/ruesga/gerrit/plugins/fcm/ApiModule.java b/src/main/java/com/ruesga/gerrit/plugins/fcm/ApiModule.java index 5ddff04..5b0079d 100644 --- a/src/main/java/com/ruesga/gerrit/plugins/fcm/ApiModule.java +++ b/src/main/java/com/ruesga/gerrit/plugins/fcm/ApiModule.java
@@ -50,8 +50,6 @@ // Configure listener handlers DynamicSet.bind(binder(), LifecycleListener.class) .to(LifeCycleHandler.class); - DynamicSet.bind(binder(), AssigneeChangedListener.class) - .to(AssigneeChangedEventHandler.class); DynamicSet.bind(binder(), ChangeAbandonedListener.class) .to(ChangeAbandonedEventHandler.class); DynamicSet.bind(binder(), ChangeMergedListener.class)
diff --git a/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java b/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java deleted file mode 100644 index af788c1..0000000 --- a/src/main/java/com/ruesga/gerrit/plugins/fcm/handlers/AssigneeChangedEventHandler.java +++ /dev/null
@@ -1,96 +0,0 @@ -/* - * Copyright (C) 2016 Jorge Ruesga - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.ruesga.gerrit.plugins.fcm.handlers; - -import com.google.gerrit.extensions.annotations.PluginName; -import com.google.gerrit.extensions.common.AccountInfo; -import com.google.gerrit.extensions.events.AssigneeChangedListener; -import com.google.gerrit.server.AnonymousUser; -import com.google.gerrit.server.IdentifiedUser.GenericFactory; -import com.google.gerrit.server.account.GroupBackend; -import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gerrit.server.config.AllProjectsName; -import com.google.gerrit.server.project.ProjectCache; -import com.google.gerrit.server.query.account.InternalAccountQuery; -import com.google.gerrit.server.query.change.ChangeQueryBuilder; -import com.google.gerrit.server.query.change.ChangeQueryProcessor; -import com.google.gson.annotations.SerializedName; -import com.google.inject.Inject; -import com.google.inject.Provider; -import com.ruesga.gerrit.plugins.fcm.messaging.Notification; -import com.ruesga.gerrit.plugins.fcm.rest.CloudNotificationEvents; -import com.ruesga.gerrit.plugins.fcm.workers.FcmUploaderWorker; - -public class AssigneeChangedEventHandler extends EventHandler - implements AssigneeChangedListener { - - private static class AssigneeInfo { - @SerializedName("old") public AccountInfo old; - @SerializedName("new") public AccountInfo _new; - } - - @Inject - public AssigneeChangedEventHandler( - @PluginName String pluginName, - FcmUploaderWorker uploader, - AllProjectsName allProjectsName, - ChangeQueryBuilder cqb, - ChangeQueryProcessor cqp, - ProjectCache projectCache, - GroupBackend groupBackend, - Provider<InternalAccountQuery> accountQueryProvider, - GenericFactory identifiedUserFactory, - Provider<AnonymousUser> anonymousProvider) { - super(pluginName, - uploader, - allProjectsName, - cqb, cqp, - projectCache, - groupBackend, - accountQueryProvider, - identifiedUserFactory, - anonymousProvider); - } - - protected int getEventType() { - return CloudNotificationEvents.ASSIGNEE_CHANGED_EVENT; - } - - protected NotifyType getNotifyType() { - return NotifyType.NEW_PATCHSETS; - } - - @Override - public void onAssigneeChanged(Event event) { - AssigneeInfo assignee = new AssigneeInfo(); - assignee.old = event.getOldAssignee(); - assignee._new = event.getChange().assignee; - Notification notification = createNotification(event); - notification.extra = getSerializer().toJson(assignee); - if (assignee._new == null) { - notification.body = formatAccount(event.getWho()) - + " unassigned " + formatAccount(assignee.old) - + " from this change"; - } else { - notification.body = formatAccount(event.getWho()) - + " assigned " + formatAccount(assignee._new) - + " to this change"; - } - - notify(notification, event); - } - -}
diff --git a/src/main/java/com/ruesga/gerrit/plugins/fcm/rest/CloudNotificationEvents.java b/src/main/java/com/ruesga/gerrit/plugins/fcm/rest/CloudNotificationEvents.java index 4fe7b0e..33ad587 100644 --- a/src/main/java/com/ruesga/gerrit/plugins/fcm/rest/CloudNotificationEvents.java +++ b/src/main/java/com/ruesga/gerrit/plugins/fcm/rest/CloudNotificationEvents.java
@@ -27,7 +27,7 @@ public static final int REVIEWER_DELETED_EVENT = 0x100; public static final int PATCHSET_CREATED_EVENT = 0x200; public static final int TOPIC_CHANGED_EVENT = 0x400; - public static final int ASSIGNEE_CHANGED_EVENT = 0x800; + // removed => public static final int ASSIGNEE_CHANGED_EVENT = 0x800; public static final int VOTE_DELETED_EVENT = 0x1000; public static final int PRIVATE_STATE_CHANGED_EVENT = 0x2000; public static final int WIP_STATE_CHANGED_EVENT = 0x4000;
diff --git a/src/main/resources/Documentation/api.md b/src/main/resources/Documentation/api.md index feaf9d2..e2365da 100644 --- a/src/main/resources/Documentation/api.md +++ b/src/main/resources/Documentation/api.md
@@ -6,7 +6,7 @@ A client application can unregistered a device (and stop receiving notifications) from the Gerrit instance using the *Unregister Cloud Notification* method. -Client applications must use a combination of fcm device identifier + a unique local account token, so they can register to listen notification for different accounts on this Gerrit instance. Token must +Client applications must use a combination of fcm device identifier + a unique local account token, so they can register to listen notification for different accounts on this Gerrit instance. Token must REST API @@ -32,7 +32,7 @@ HTTP1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 - + )]}' { "senderId": "322112333" @@ -56,7 +56,7 @@ HTTP1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 - + )]}' [ { @@ -86,7 +86,7 @@ HTTP1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 - + )]}' { "device": "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1", @@ -109,7 +109,7 @@ POST /accounts/self/devices/bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1/tokens Content-Type: application/json - + { "token": "f986567456f107d0eb2d84c85ac5aed2", "events": 8, @@ -123,7 +123,7 @@ HTTP1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 - + )]}' { "deviceId": "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1", @@ -212,8 +212,6 @@ `TOPIC_CHANGED_EVENT = 0x200` -`ASSIGNEE_CHANGED_EVENT = 0x800` - `VOTE_DELETED_EVENT = 0x1000` `PRIVATE_STATE_CHANGED_EVENT = 0x2000`