notifications: add implementation for invitations

GitLab: #178
Change-Id: If6c881b9d42a674ffb7582eb50c8e41d24f76d10
diff --git a/Ring/jamiNotificationExtension/Adapter.mm b/Ring/jamiNotificationExtension/Adapter.mm
index 06e73bd..9aa2578 100644
--- a/Ring/jamiNotificationExtension/Adapter.mm
+++ b/Ring/jamiNotificationExtension/Adapter.mm
@@ -135,6 +135,25 @@
                                                                     hasVideo:hasVideo];
             }
         }));
+    //Contact added signal
+    confHandlers.insert(exportable_callback<ConfigurationSignal::ContactAdded>([&](const std::string& accountId,
+                                                                                   const std::string& uri,
+                                                                                   bool confirmed) {
+        if(Adapter.delegate) {
+            NSString* accountIdStr = [NSString stringWithUTF8String:accountId.c_str()];
+            NSString* uriStr = [NSString stringWithUTF8String:uri.c_str()];
+            [Adapter.delegate receivedContactRequestWithAccountId: accountIdStr peerId: uriStr];
+        }
+    }));
+
+    confHandlers.insert(exportable_callback<ConversationSignal::ConversationRequestReceived>([&](const std::string& accountId, const std::string& conversationId, std::map<std::string, std::string> metadata) {
+        if(Adapter.delegate) {
+            NSString* accountIdStr = [NSString stringWithUTF8String:accountId.c_str()];
+            NSString* convIdStr = [NSString stringWithUTF8String:conversationId.c_str()];
+            NSMutableDictionary* info = [Utils mapToDictionnary: metadata];
+            [Adapter.delegate receivedConversationRequestWithAccountId: accountIdStr conversationId: convIdStr metadata:info];
+        }
+    }));
     registerSignalHandlers(confHandlers);
 }
 
@@ -229,6 +248,18 @@
         dht::Sp<dht::Value> decrypted = dhtValue.decrypt(dhtKey);
         auto unpacked = msgpack::unpack((const char*) decrypted->data.data(), decrypted->data.size());
         auto peerCR = unpacked.get().as<PeerConnectionRequest>();
+        if (peerCR.connType.empty()) {
+            // this value is not a PeerConnectionRequest
+            // check if it a TrustRequest
+            auto conversationRequest = unpacked.get().as<dht::TrustRequest>();
+            if (!conversationRequest.conversationId.empty()) {
+                if (conversationRequest.service == "cx.ring") {
+                    // return git message type to start daemon
+                    return @{@"": @"application/im-gitmessage-id"};
+                }
+            }
+            return {};
+        }
         if (isMessageTreated(peerCR.id, [treatedMessagesPath UTF8String])) {
             return {};
         }