From 3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4 Mon Sep 17 00:00:00 2001
From: Debanshu Kundu <debanshu.kundu@joshtechnologygroup.com>
Date: Fri, 20 Jan 2017 23:11:13 +0530
Subject:  #4257 Added functionality to create previews for post links using
 open graph data from those links. (#4890)

---
 webapp/actions/global_actions.jsx | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

(limited to 'webapp/actions/global_actions.jsx')

diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index 4cfcaa6cb..23e19f22f 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -596,3 +596,27 @@ export function redirectUserToDefaultTeam() {
         browserHistory.push('/select_team');
     }
 }
+
+requestOpenGraphMetadata.openGraphMetadataOnGoingRequests = {};  // Format: {<url>: true}
+export function requestOpenGraphMetadata(url) {
+    const onself = requestOpenGraphMetadata;
+
+    if (!onself.openGraphMetadataOnGoingRequests[url]) {
+        onself.openGraphMetadataOnGoingRequests[url] = true;
+
+        Client.getOpenGraphMetadata(url,
+            (data) => {
+                AppDispatcher.handleServerAction({
+                    type: ActionTypes.RECIVED_OPEN_GRAPH_METADATA,
+                    url,
+                    data
+                });
+                delete onself.openGraphMetadataOnGoingRequests[url];
+            },
+            (err) => {
+                AsyncClient.dispatchError(err, 'getOpenGraphMetadata');
+                delete onself.openGraphMetadataOnGoingRequests[url];
+            }
+        );
+    }
+}
-- 
cgit v1.2.3-1-g7c22

