Index: feedapi_node/feedapi_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/feedapi_node/Attic/feedapi_node.module,v
retrieving revision 1.1.2.18.2.35
diff -u -p -r1.1.2.18.2.35 feedapi_node.module
--- feedapi_node/feedapi_node.module	2 Jul 2009 16:38:16 -0000	1.1.2.18.2.35
+++ feedapi_node/feedapi_node.module	10 Aug 2009 20:09:26 -0000
@@ -297,13 +338,17 @@ function _feedapi_node_save($feed_item, 
     $node->status = 1;
   }
   $feed_node = node_load($feed_nid);
-
-  $type = node_get_types('type', $node->type);
-  if ($type->has_title) {
-    $node->title = $feed_item->title;
+  if (function_exists('feedapi_mapper_map')) {
+    $node = feedapi_mapper_map($feed_node, 'feedapi_node', $feed_item, $node);
   }
-  if ($type->has_body) {
-    $node->body = $feed_item->description;
+  else {
+    $type = node_get_types('type', $node->type);
+    if ($type->has_title) {
+      $node->title = $feed_item->title;
+    }
+    if ($type->has_body) {
+      $node->body = $feed_item->description;
+    }
   }
   $node->format = isset($settings['input_format']) ? $settings['input_format'] : FILTER_FORMAT_DEFAULT;
   $node->teaser = node_teaser($feed_item->description);
@@ -409,6 +454,48 @@ function _feedapi_node_purge($feed) {
  *  TRUE if the item is new, FALSE if the item is a duplicated one
  */
 function _feedapi_node_unique($feed_item, $feed_nid, $settings) {
+  // Let the mapper hijack the decision
+  if (function_exists('feedapi_mapper_unique')) {
+    $feed_node = node_load($feed_nid);
+    $result = feedapi_mapper_unique($feed_node, 'feedapi_node', $feed_item);
+    if ($result === FALSE) {
+      // No user-defined mapping, use the built-in mapping logic (url with guid fallback)
+      unset($result);
+    }
+  }
+  if (isset($result)) {
+    if (empty($result)) {
+      return TRUE;
+    }
+    if (!$settings['x_dedupe']) {
+      // Filter out unneeded result, only the items from the same feeds are needed
+      foreach ($result as $field => $dup_items) {
+        foreach ($dup_items as $item_id => $feed_nids) {
+          if (!in_array($feed_nid, $feed_nids)) {
+            unset($result[$field][$item_id]);
+	   }
+	 }
+	 if (count($result[$field]) == 0) {
+          unset($result[$field]);
+        }
+      }
+      if (empty($result)) {
+        return TRUE;
+      }
+      // This is an item id
+      return array_pop(array_keys(array_pop($result)));
+    }
+    // OR connection between the fields
+    // If no cross-feed deduping, it's over here, the array is
+    else {
+      foreach ($result as $dup_items) {
+        foreach ($dup_items as $item_id => $feed_nids) {
+          $feed_item->feedapi_node->duplicates[$item_id] = array_merge($feed_nids, (array) $feed_item->feedapi_node->duplicates[$item_id]);
+        }
+      }
+      return $item_id;
+    }
+  }
   if (empty($feed_item->options->original_url)) {
     unset($feed_item->options->original_url);
   }
