]> git.mxchange.org Git - friendica-addons.git/commitdiff
Prevent posting loops
authorMichael <heluecht@pirati.ca>
Mon, 7 Nov 2016 05:23:19 +0000 (05:23 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 7 Nov 2016 05:23:19 +0000 (05:23 +0000)
fromgplus/fromgplus.php
statusnet/statusnet.php
twitter/twitter.php

index c8026ad3a99b1ed91f5284df2b2efef07baae3f6..4c96892c662d94efd9ff9cdee6ee5742bc3c94d9 100644 (file)
@@ -39,6 +39,7 @@ function fromgplus_addon_settings(&$a,&$s) {
                return;
 
        $enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : '');
+       $keywords_checked = (intval(get_pconfig(local_user(), 'fromgplus', 'keywords')) ? ' checked="checked"' : '');
        $account = get_pconfig(local_user(),'fromgplus','account');
 
        $s .= '<span id="settings_fromgplus_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
@@ -57,6 +58,9 @@ function fromgplus_addon_settings(&$a,&$s) {
        $s .= '<label id="fromgplus-label" for="fromgplus-account">'.t('Google Account ID').' </label>';
        $s .= '<input id="fromgplus-account" type="text" name="fromgplus-account" value="'.$account.'" />';
        $s .= '</div><div class="clear"></div>';
+       $s .= '<label id="fromgplus-keywords-label" for="fromgplus-keywords">'.t('Add keywords to post').'</label>';
+       $s .= '<input id="fromgplus-keywords" type="checkbox" name="fromgplus-keywords" value="1"'.$keywords_checked.' />';
+       $s .= '<div class="clear"></div>';
 
        $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="fromgplus-submit" name="fromgplus-submit" 
 class="settings-submit" value="' . t('Save Settings') . '" /></div>';
@@ -74,6 +78,8 @@ function fromgplus_addon_settings_post(&$a,&$b) {
                set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
                $enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0);
                set_pconfig(local_user(),'fromgplus','enable', $enable);
+               $keywords = ((x($_POST, 'fromgplus-keywords')) ? intval($_POST['fromgplus-keywords']) : 0);
+               set_pconfig(local_user(),'fromgplus', 'keywords', $keywords);
 
                if (!$enable)
                        del_pconfig(local_user(),'fromgplus','lastdate');
@@ -130,7 +136,7 @@ function fromgplus_cron($a,$b) {
        set_config('fromgplus','last_poll', time());
 }
 
-function fromgplus_post($a, $uid, $source, $body, $location, $coord) {
+function fromgplus_post($a, $uid, $source, $body, $location, $coord, $id) {
 
        //$uid = 2;
 
@@ -158,6 +164,9 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord) {
        $_REQUEST['source'] = $source;
        $_REQUEST['extid'] = NETWORK_GPLUS;
 
+       if (isset($id))
+               $_REQUEST['message_id'] = NETWORK_GPLUS.":".$id;
+
        // $_REQUEST['verb']
        // $_REQUEST['parent']
        // $_REQUEST['parent_uri']
@@ -327,9 +336,9 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
 
                                // Add Keywords to page link
                                $data = parseurl_getsiteinfo_cached($pagedata["url"], true);
-                               if (isset($data["keywords"]))
+                               if (isset($data["keywords"]) AND get_pconfig($uid, 'fromgplus', 'keywords')) {
                                        $pagedata["keywords"] = $data["keywords"];
-
+                               }
                                break;
 
                        case "photo":
@@ -452,6 +461,8 @@ function fromgplus_fetch($a, $uid) {
                if ($lastdate < strtotime($item->published))
                        $lastdate = strtotime($item->published);
 
+               set_pconfig($uid,'fromgplus','lastdate', $lastdate);
+
                if ($first_time)
                        continue;
 
@@ -485,7 +496,7 @@ function fromgplus_fetch($a, $uid) {
                                        } elseif (isset($item->address))
                                                $location = $item->address;
 
-                                       fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord);
+                                       fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord, $item->id);
 
                                        break;
 
@@ -536,7 +547,7 @@ function fromgplus_fetch($a, $uid) {
                                        } elseif (isset($item->address))
                                                $location = $item->address;
 
-                                       fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord);
+                                       fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord, $item->id);
                                        break;
                        }
                }
index 4fdd6a74b818b2f7b5f3b4606556a85fa013f7d2..febe4032f19d1c7f4566fdd43295f40e4b0e1833 100644 (file)
@@ -872,6 +872,9 @@ function statusnet_fetchtimeline($a, $uid) {
                        $_REQUEST["source"] = $post->source;
                        $_REQUEST["extid"] = NETWORK_STATUSNET;
 
+                       if (isset($post->id))
+                               $_REQUEST['message_id'] = NETWORK_STATUSNET.":".$post->id;
+
                        //$_REQUEST["date"] = $post->created_at;
 
                        $_REQUEST["title"] = "";
index 8f023dfeb4608f66b5bf38bb9e468cde6d1136f1..e7429696dec1339d717aa025ddf87e6a40bb9dde 100644 (file)
@@ -791,6 +791,9 @@ function twitter_fetchtimeline($a, $uid) {
                        $_REQUEST["source"] = $post->source;
                        $_REQUEST["extid"] = NETWORK_TWITTER;
 
+                       if (isset($post->id))
+                               $_REQUEST['message_id'] = NETWORK_TWITTER.":".$post->id;
+
                        //$_REQUEST["date"] = $post->created_at;
 
                        $_REQUEST["title"] = "";