From a109c1cb659d622540df4609d9e7ac2d5c2cfe07 Mon Sep 17 00:00:00 2001
From: Kajan <kajan@vedaconsulting.co.uk>
Date: Wed, 14 Oct 2015 13:09:46 +0100
Subject: [PATCH 1/3] Return webhook if api set for webhook setting for list

---
 CRM/Mailchimp/Page/WebHook.php | 7 +++++++
 info.xml                       | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/CRM/Mailchimp/Page/WebHook.php b/CRM/Mailchimp/Page/WebHook.php
index 769a772..83db0bc 100644
--- a/CRM/Mailchimp/Page/WebHook.php
+++ b/CRM/Mailchimp/Page/WebHook.php
@@ -25,6 +25,13 @@ function run() {
     if (!empty($_POST['data']['list_id']) && !empty($_POST['type'])) {
       $requestType = $_POST['type'];
       $requestData = $_POST['data'];
+      // Return if API is set in webhook setting for lists
+      $list	      = new Mailchimp_Lists(CRM_Mailchimp_Utils::mailchimp());
+      $webhookoutput  = $list->webhooks($requestData['list_id']);
+      if($webhookoutput[0]['sources']['api'] == 1) {
+	CRM_Mailchimp_Utils::checkDebug('CRM_Mailchimp_Page_WebHook run API is set in Webhook setting for listID', $requestData['list_id'] );
+	return;      
+      }
 
       switch ($requestType) {
        case 'subscribe':
diff --git a/info.xml b/info.xml
index 52c08bb..e7a7424 100644
--- a/info.xml
+++ b/info.xml
@@ -8,8 +8,8 @@
     <author>Deepak Srivastava, Kajan, Parvez Saleh and Rich Lott (Artful Robot)</author>
     <email>support@vedaconsulting.co.uk</email>
   </maintainer>
-  <releaseDate>2015-08-27</releaseDate>
-  <version>1.8.2</version>
+  <releaseDate>2015-10-14</releaseDate>
+  <version>1.8.3</version>
   <develStage>stable</develStage>
   <compatibility>
     <ver>4.4</ver>

From 4cf05f2823ecb492478b65ea097faf39766ff7ca Mon Sep 17 00:00:00 2001
From: Kajan <kajan@vedaconsulting.co.uk>
Date: Wed, 14 Oct 2015 17:24:52 +0100
Subject: [PATCH 2/3] Readme change

---
 README.md | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 3d34054..d0337c0 100644
--- a/README.md
+++ b/README.md
@@ -97,13 +97,10 @@ sending a request to Mailchimp for every affected contact would be very slow.
 
 ### Important note about unsubscribed contacts
 
-Note: currently, removals are processed as unsubscribes from Mailchimp. This is
-so that Mailchimp's reporting and subscriber history is not affected by
-removals. However, Mailchimp treats unsubscribed people in a bit of a permanent
-way; you cannot ever re-subscribe them! This is caution on Mailchimp's part, as
-they have to ensure their service is not used by spammers. However it's an awkward
-feature for the general integration case. The only way to re-subscribe someone
-who previously unsubscribed is to first delete them from the Mailchimp list.
+Note: If anybody is added/removed to group in civiCRM, they get subscribed/unsubscribed to Mailchimp immediately.
+If Webhook is set properly in Mailchimp, then subscribe/unsubscribe in Mailchimp is treated back to civiCRM
+immediately as addition/deletion to group
+
 
 We have an upcoming feature that will give you the option to force
 a CiviCRM to Mailchimp sync which will automatically do the necessary deletions,

From 9e03992c512143b02079a7ce1c4f8e710bceb52b Mon Sep 17 00:00:00 2001
From: Kajan <kajan@vedaconsulting.co.uk>
Date: Tue, 20 Oct 2015 14:30:50 +0100
Subject: [PATCH 3/3] revert info

---
 info.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/info.xml b/info.xml
index e7a7424..52c08bb 100644
--- a/info.xml
+++ b/info.xml
@@ -8,8 +8,8 @@
     <author>Deepak Srivastava, Kajan, Parvez Saleh and Rich Lott (Artful Robot)</author>
     <email>support@vedaconsulting.co.uk</email>
   </maintainer>
-  <releaseDate>2015-10-14</releaseDate>
-  <version>1.8.3</version>
+  <releaseDate>2015-08-27</releaseDate>
+  <version>1.8.2</version>
   <develStage>stable</develStage>
   <compatibility>
     <ver>4.4</ver>