Merge pull request #382 from annando/1603-fromgplus-keywords

Google+/Twitter/GNU Social: Prevent posting loops when mirroring posts
This commit is contained in:
Tobias Diekershoff 2016-11-12 18:56:41 +01:00 committed by GitHub
commit 24638894a6
5 changed files with 59 additions and 24 deletions

View file

@ -10,6 +10,7 @@
define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
require_once('mod/share.php'); require_once('mod/share.php');
require_once('mod/parse_url.php');
function fromgplus_install() { function fromgplus_install() {
register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings'); register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
@ -38,6 +39,7 @@ function fromgplus_addon_settings(&$a,&$s) {
return; return;
$enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : ''); $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'); $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\');">'; $s .= '<span id="settings_fromgplus_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
@ -56,6 +58,9 @@ function fromgplus_addon_settings(&$a,&$s) {
$s .= '<label id="fromgplus-label" for="fromgplus-account">'.t('Google Account ID').' </label>'; $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 .= '<input id="fromgplus-account" type="text" name="fromgplus-account" value="'.$account.'" />';
$s .= '</div><div class="clear"></div>'; $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" $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="fromgplus-submit" name="fromgplus-submit"
class="settings-submit" value="' . t('Save Settings') . '" /></div>'; class="settings-submit" value="' . t('Save Settings') . '" /></div>';
@ -73,6 +78,8 @@ function fromgplus_addon_settings_post(&$a,&$b) {
set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account'])); set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
$enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0); $enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0);
set_pconfig(local_user(),'fromgplus','enable', $enable); 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) if (!$enable)
del_pconfig(local_user(),'fromgplus','lastdate'); del_pconfig(local_user(),'fromgplus','lastdate');
@ -129,7 +136,7 @@ function fromgplus_cron($a,$b) {
set_config('fromgplus','last_poll', time()); 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; //$uid = 2;
@ -157,6 +164,9 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord) {
$_REQUEST['source'] = $source; $_REQUEST['source'] = $source;
$_REQUEST['extid'] = NETWORK_GPLUS; $_REQUEST['extid'] = NETWORK_GPLUS;
if (isset($id))
$_REQUEST['message_id'] = NETWORK_GPLUS.":".$id;
// $_REQUEST['verb'] // $_REQUEST['verb']
// $_REQUEST['parent'] // $_REQUEST['parent']
// $_REQUEST['parent_uri'] // $_REQUEST['parent_uri']
@ -324,6 +334,11 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
if ($quote != "") if ($quote != "")
$pagedata["text"] = $quote; $pagedata["text"] = $quote;
// Add Keywords to page link
$data = parseurl_getsiteinfo_cached($pagedata["url"], true);
if (isset($data["keywords"]) AND get_pconfig($uid, 'fromgplus', 'keywords')) {
$pagedata["keywords"] = $data["keywords"];
}
break; break;
case "photo": case "photo":
@ -446,6 +461,8 @@ function fromgplus_fetch($a, $uid) {
if ($lastdate < strtotime($item->published)) if ($lastdate < strtotime($item->published))
$lastdate = strtotime($item->published); $lastdate = strtotime($item->published);
set_pconfig($uid,'fromgplus','lastdate', $lastdate);
if ($first_time) if ($first_time)
continue; continue;
@ -479,7 +496,7 @@ function fromgplus_fetch($a, $uid) {
} elseif (isset($item->address)) } elseif (isset($item->address))
$location = $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; break;
@ -530,7 +547,7 @@ function fromgplus_fetch($a, $uid) {
} elseif (isset($item->address)) } elseif (isset($item->address))
$location = $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; break;
} }
} }

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-27 05:01-0500\n" "POT-Creation-Date: 2016-11-12 16:52+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,22 +17,34 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: fromgplus.php:33 #: fromgplus.php:46 fromgplus.php:50
msgid "Google+ Import Settings" msgid "Google+ Mirror"
msgstr "" msgstr ""
#: fromgplus.php:36 #: fromgplus.php:55
msgid "Enable Google+ Import" msgid "Enable Google+ Import"
msgstr "" msgstr ""
#: fromgplus.php:39 #: fromgplus.php:58
msgid "Google Account ID" msgid "Google Account ID"
msgstr "" msgstr ""
#: fromgplus.php:44 #: fromgplus.php:61
msgid "Submit" msgid "Add keywords to post"
msgstr "" msgstr ""
#: fromgplus.php:59 #: fromgplus.php:66 fromgplus.php:95
msgid "Save Settings"
msgstr ""
#: fromgplus.php:87
msgid "Google+ Import Settings saved." msgid "Google+ Import Settings saved."
msgstr "" msgstr ""
#: fromgplus.php:96
msgid "Key"
msgstr ""
#: fromgplus.php:103
msgid "Settings updated."
msgstr ""

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-23 14:44+0200\n" "POT-Creation-Date: 2016-11-12 16:50+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,50 +17,50 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: gpluspost.php:38 #: gpluspost.php:39
msgid "Post to Google+" msgid "Post to Google+"
msgstr "" msgstr ""
#: gpluspost.php:93 #: gpluspost.php:94
msgid "Enable Google+ Post Plugin" msgid "Enable Google+ Post Plugin"
msgstr "" msgstr ""
#: gpluspost.php:108 #: gpluspost.php:109
msgid "Google+ username" msgid "Google+ username"
msgstr "" msgstr ""
#: gpluspost.php:113 #: gpluspost.php:114
msgid "Google+ password" msgid "Google+ password"
msgstr "" msgstr ""
#: gpluspost.php:118 #: gpluspost.php:119
msgid "Google+ page number" msgid "Google+ page number"
msgstr "" msgstr ""
#: gpluspost.php:124 #: gpluspost.php:125
msgid "Post to Google+ by default" msgid "Post to Google+ by default"
msgstr "" msgstr ""
#: gpluspost.php:129 #: gpluspost.php:130
msgid "Do not prevent posting loops" msgid "Do not prevent posting loops"
msgstr "" msgstr ""
#: gpluspost.php:135 #: gpluspost.php:136
msgid "Skip messages without links" msgid "Skip messages without links"
msgstr "" msgstr ""
#: gpluspost.php:142 #: gpluspost.php:143
msgid "Mirror all public posts" msgid "Mirror all public posts"
msgstr "" msgstr ""
#: gpluspost.php:146 #: gpluspost.php:147
msgid "Mirror Google Account ID" msgid "Mirror Google Account ID"
msgstr "" msgstr ""
#: gpluspost.php:153 #: gpluspost.php:154
msgid "Save Settings" msgid "Save Settings"
msgstr "" msgstr ""
#: gpluspost.php:308 #: gpluspost.php:310
msgid "Google+ post failed. Queued for retry." msgid "Google+ post failed. Queued for retry."
msgstr "" msgstr ""

View file

@ -872,6 +872,9 @@ function statusnet_fetchtimeline($a, $uid) {
$_REQUEST["source"] = $post->source; $_REQUEST["source"] = $post->source;
$_REQUEST["extid"] = NETWORK_STATUSNET; $_REQUEST["extid"] = NETWORK_STATUSNET;
if (isset($post->id))
$_REQUEST['message_id'] = NETWORK_STATUSNET.":".$post->id;
//$_REQUEST["date"] = $post->created_at; //$_REQUEST["date"] = $post->created_at;
$_REQUEST["title"] = ""; $_REQUEST["title"] = "";

View file

@ -791,6 +791,9 @@ function twitter_fetchtimeline($a, $uid) {
$_REQUEST["source"] = $post->source; $_REQUEST["source"] = $post->source;
$_REQUEST["extid"] = NETWORK_TWITTER; $_REQUEST["extid"] = NETWORK_TWITTER;
if (isset($post->id))
$_REQUEST['message_id'] = NETWORK_TWITTER.":".$post->id;
//$_REQUEST["date"] = $post->created_at; //$_REQUEST["date"] = $post->created_at;
$_REQUEST["title"] = ""; $_REQUEST["title"] = "";