Merge pull request #199 from annando/master

app.net/expire of facebook and twitter posts
This commit is contained in:
tobiasd 2014-06-12 07:55:19 +02:00
commit ec8384df66
11 changed files with 3241 additions and 443 deletions

1647
appnet/AppDotNet.php Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL
MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm
+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW
PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM
xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB
Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3
hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg
EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF
MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA
FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec
nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z
eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF
hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
+OkuE6N36B9K
-----END CERTIFICATE-----

29
appnet/appnet.css Executable file
View file

@ -0,0 +1,29 @@
#appnet-import-label, #appnet-disconnect-label, #appnet-token-label,
#appnet-enable-label, #appnet-bydefault-label,
#appnet-clientid-label, #appnet-clientsecret-label {
float: left;
width: 200px;
margin-top: 10px;
}
#appnet-import, #appnet-disconnect, #appnet-token,
#appnet-checkbox, #appnet-bydefault,
#appnet-clientid, #appnet-clientsecret {
float: left;
margin-top: 10px;
}
#appnet-submit {
margin-top: 15px;
}
#appnet-avatar {
float: left;
width: 48px;
height: 48px;
padding: 2px;
}
#appnet-info-block {
height: 52px;
vertical-align: middle;
}

1047
appnet/appnet.php Normal file

File diff suppressed because it is too large Load diff

0
appnetpost/appnetpost.css Executable file → Normal file
View file

View file

@ -248,7 +248,7 @@ function fbpost_content(&$a) {
//read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,create_note,share_item,video_upload,status_update">' . t('Install Facebook Post connector for this account.') . '</a>';
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update">' . t('Install Facebook Post connector for this account.') . '</a>';
$o .= '</div>';
}
@ -260,7 +260,7 @@ function fbpost_content(&$a) {
$o .= '<div id="fbpost-enable-wrapper">';
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,create_note,share_item,video_upload,status_update">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
$o .= '</div>';
$o .= '<div id="fbpost-post-default-form">';
@ -666,11 +666,13 @@ function fbpost_post_hook(&$a,&$b) {
$postvars['message'] = $msg;
$url = 'https://graph.facebook.com/'.$target.'/photos';
} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
//} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
} else {
$url = 'https://graph.facebook.com/'.$target.'/feed';
if (!get_pconfig($b['uid'],'facebook','suppress_view_on_friendica') and $b['plink'])
$postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
} else {
}
/* } else {
// if its only a message and a subject and the message is larger than 500 characters then post it as note
$postvars = array(
'access_token' => $fb_token,
@ -678,7 +680,7 @@ function fbpost_post_hook(&$a,&$b) {
'subject' => $b['title'],
);
$url = 'https://graph.facebook.com/'.$target.'/notes';
}
} */
// Post to page?
if (!$reply and ($target != "me") and $page_access_token)
@ -946,6 +948,7 @@ function fbpost_cron($a,$b) {
function fbpost_fetchwall($a, $uid) {
require_once("include/oembed.php");
require_once('mod/item.php');
$access_token = get_pconfig($uid,'facebook','access_token');
$post_to_page = get_pconfig($uid,'facebook','post_to_page');
@ -1081,8 +1084,6 @@ function fbpost_fetchwall($a, $uid) {
//print_r($_REQUEST);
logger('facebook: posting for user '.$uid);
require_once('mod/item.php');
item_post($a);
}

View file

@ -26,6 +26,7 @@ function fbsync_install() {
register_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
register_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
register_hook('follow', 'addon/fbsync/fbsync.php', 'fbsync_follow');
register_hook('expire', 'addon/fbsync/fbsync.php', 'fbsync_expire');
}
function fbsync_uninstall() {
@ -33,6 +34,7 @@ function fbsync_uninstall() {
unregister_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
unregister_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
unregister_hook('follow', 'addon/fbsync/fbsync.php', 'fbsync_follow');
unregister_hook('expire', 'addon/fbsync/fbsync.php', 'fbsync_expire');
}
function fbsync_follow($a, &$contact) {
@ -185,6 +187,30 @@ function fbsync_cron($a,$b) {
set_config('fbsync','last_poll', time());
}
function fbsync_expire($a,$b) {
$days = get_config('fbsync', 'expire');
if ($days == 0)
return;
$r = q("DELETE FROM `item` WHERE `deleted` AND `network` = '%s'", dbesc(NETWORK_FACEBOOK));
require_once("include/items.php");
logger('fbsync_expire: expire_start');
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'fbsync' AND `k` = 'sync' AND `v` = '1' ORDER BY RAND()");
if(count($r)) {
foreach($r as $rr) {
logger('fbsync_expire: user '.$rr['uid']);
item_expire($rr['uid'], $days, NETWORK_FACEBOOK, true);
}
}
logger('fbsync_expire: expire_end');
}
function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
require_once("include/oembed.php");
@ -1018,7 +1044,6 @@ function fbsync_fetchfeed($a, $uid) {
foreach ($post_data AS $post) {
if ($post->updated_time > $last_updated)
$last_updated = $post->updated_time;
fbsync_createpost($a, $uid, $self, $contacts, $application_data, $post, $create_user);
}

1
pumpio/pumpio.php Executable file → Normal file
View file

@ -283,7 +283,6 @@ function pumpio_settings(&$a,&$s) {
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
}

View file

@ -1429,7 +1429,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
$expanded_url = original_url($match[1]);
$oembed_data = oembed_fetch_url($expanded_url, true);
print_r($oembed_data);
if ($type == "")
$type = $oembed_data->type;
if ($oembed_data->type == "video") {

0
tumblr/tumblr.php Executable file → Normal file
View file

37
twitter/twitter.php Executable file → Normal file
View file

@ -72,6 +72,7 @@ function twitter_install() {
register_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
register_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
logger("installed twitter");
}
@ -85,6 +86,7 @@ function twitter_uninstall() {
unregister_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
unregister_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
unregister_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
// old setting - remove only
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
@ -401,11 +403,13 @@ function twitter_post_hook(&$a,&$b) {
$orig_post = $r[0];
}
$nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
$nickname = "@[url=".$orig_post["author-link"]."]".$nickname."[/url]";
logger("twitter_post_hook: comparing ".$nickname." with ".$b["body"], LOGGER_DEBUG);
if (strpos($b["body"], $nickname) === false)
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
$nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
$nicknameplain = "@".$nicknameplain;
logger("twitter_post_hook: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
if ((strpos($b["body"], $nickname) === false) AND (strpos($b["body"], $nicknameplain) === false))
$b["body"] = $nickname." ".$b["body"];
logger("twitter_post_hook: parent found ".print_r($orig_post, true), LOGGER_DATA);
@ -624,6 +628,30 @@ function twitter_cron($a,$b) {
set_config('twitter','last_poll', time());
}
function twitter_expire($a,$b) {
$days = get_config('twitter', 'expire');
if ($days == 0)
return;
$r = q("DELETE FROM `item` WHERE `deleted` AND `network` = '%s'", dbesc(NETWORK_TWITTER));
require_once("include/items.php");
logger('twitter_expire: expire_start');
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
if(count($r)) {
foreach($r as $rr) {
logger('twitter_expire: user '.$rr['uid']);
item_expire($rr['uid'], $days, NETWORK_TWITTER, true);
}
}
logger('twitter_expire: expire_end');
}
function twitter_fetchtimeline($a, $uid) {
$ckey = get_config('twitter', 'consumerkey');
$csecret = get_config('twitter', 'consumersecret');
@ -1610,5 +1638,4 @@ function twitter_is_retweet($a, $uid, $body) {
return(!isset($result->errors));
}
?>